public static function insert(array $data)
{
$self = static::getInstance();
$data = $self->filterColumns($data);
if (!sizeof($data)) {
throw new DbException("Invalid field names of table `{$self->table}`. Please check use of `insert()` method");
}
$table = DbProxy::quoteIdentifier($self->table);
$sql = "INSERT INTO {$table} SET " . join(',', self::prepareStatement($data));
$result = DbProxy::query($sql, array_values($data));
if (!$result) {
return null;
}
/**
* If a sequence name was not specified for the name parameter, PDO::lastInsertId()
* returns a string representing the row ID of the last row that was inserted into the database.
*
* If a sequence name was specified for the name parameter, PDO::lastInsertId()
* returns a string representing the last value retrieved from the specified sequence object.
*
* If the PDO driver does not support this capability, PDO::lastInsertId() triggers an IM001 SQLSTATE.
*/
return DbProxy::handler()->lastInsertId($self->sequence);
}