[eluser]appleboy[/eluser]
I think that your model code as follows:
Code:
class Members extends CI_Model {
public function register($username = NULL, $password = NULL, $email = NULL){
$sqlq = "INSERT INTO members VALUES(?, ?, ?, ?)";
$this->db->query($sqlq, array(NULL, $username, $password, $email));
}
}
It's all right that use default value to replace condition.
You can referrer system/database/DB_driver.php
Code:
/**
* Compile Bindings
*
* @access public
* @param string the sql statement
* @param array an array of bind data
* @return string
*/
function compile_binds($sql, $binds)
{
if (strpos($sql, $this->bind_marker) === FALSE)
{
return $sql;
}
if ( ! is_array($binds))
{
$binds = array($binds);
}
// Get the sql segments around the bind markers
$segments = explode($this->bind_marker, $sql);
// The count of bind should be 1 less then the count of segments
// If there are more bind arguments trim it down
if (count($binds) >= count($segments)) {
$binds = array_slice($binds, 0, count($segments)-1);
}
// Construct the binded query
$result = $segments[0];
$i = 0;
foreach ($binds as $bind)
{
$result .= $this->escape($bind);
$result .= $segments[++$i];
}
return $result;
}