[eluser]Seppo[/eluser]
Using current SVN version, all empty fields are saved as NULL. This can be awful when restoring the DB...
Current SVN version (mysql_utility.php, rows 211 to 243)
Code:
foreach ($row as $v)
{
// Do a little formatting...
$v = str_replace(array("\x00", "\x0a", "\x0d", "\x1a"), array('\', '\n', '\r', '\Z'), $v);
$v = str_replace(array("\n", "\r", "\t"), array('\n', '\r', '\t'), $v);
$v = str_replace('\\', '\\\\', $v);
$v = str_replace('\'', '\\\'', $v);
$v = str_replace('\\\n', '\n', $v);
$v = str_replace('\\\r', '\r', $v);
$v = str_replace('\\\t', '\t', $v);
// Is the value NULL?
if ($v == NULL)
{
$val_str .= 'NULL';
}
else
{
// Escape the data if it's not an integer
if ($is_int[$i] == FALSE)
{
$val_str .= $this->db->escape($v);
}
else
{
$val_str .= $v;
}
}
// Append a comma
$val_str .= ', ';
$i++;
}
My suggestion
Code:
foreach ($row as $v)
{
// Is the value NULL?
if ($v === NULL)
{
$val_str .= 'NULL';
}
else
{
// Do a little formatting...
$v = str_replace(array("\x00", "\x0a", "\x0d", "\x1a"), array('\', '\n', '\r', '\Z'), $v);
$v = str_replace(array("\n", "\r", "\t"), array('\n', '\r', '\t'), $v);
$v = str_replace('\\', '\\\\', $v);
$v = str_replace('\'', '\\\'', $v);
$v = str_replace('\\\n', '\n', $v);
$v = str_replace('\\\r', '\r', $v);
$v = str_replace('\\\t', '\t', $v);
// Escape the data if it's not an integer
if ($is_int[$i] == FALSE)
{
$val_str .= $this->db->escape($v);
}
else
{
$val_str .= $v;
}
}
// Append a comma
$val_str .= ', ';
$i++;
}