- edited description
Allowing empty insert to trigger mysql auto values
Issue #28
open
Whene I tried it, it raised an error, the solution to the errror was to define the arrays keys & values as empty arrays at first.
public function insert($table, $data)
{
$keys = array();
$values = array();
if (isset($this -> table_prefixfix))
$table = $this -> table_prefix . $table;
foreach ($data as $key => $value)
{
$keys[] = "`$key`";
if (strpos($value, '()') == true)
$values[] = "$value";
else
$values[] = "'$value'";
}
$this -> _query = "INSERT INTO " . $table . " (" . implode(', ', $keys) . ") VALUES (" . implode(', ', $values) . ");";
$this -> execute();
return $this -> _mysqli -> insert_id;
}
Comments (6)
-
reporter -
reporter - edited description
-
repo owner - changed status to duplicate
Duplicate of #27.
-
repo owner - changed status to open
-
repo owner What was the error that you got and what are the exact code to replicate it ?
-
repo owner What is the error severity ? Is it Fatal or just Notice ?
- Log in to comment