2006-03-22, 03:28 PM
As suggestion the functions should check if $value starts with SELECT and don't add quotes for these values.
Or add an optional array/string param which contains fieldnames which don't need quotes.
This could make the live sometimes easyer.
The function can look like:
Or add an optional array/string param which contains fieldnames which don't need quotes.
This could make the live sometimes easyer.
The function can look like:
function insert_query($table, $array, $ignore = null)
{
if(!is_array($array))
{
return false;
}
foreach($array as $field => $value)
{
$query1 .= $comma.$field;
if (is_string($ignore) && $field == $ignore)
$query2 .= $comma.$value;
elseif (is_array($ignore) && array_key_exists($field, $ignore))
$query2 .= $comma.$value;
else
$query2 .= $comma."'".$value."'";
$comma = ", ";
}
return $this->query("INSERT INTO ".$table." (".$query1.") VALUES (".$query2.");");
}