/** * Insert a row * @param string $table * @param array $aValues Array of couple field => value * @return mixed */ public function insert($table, $aValues) { $table = $this->quoteTable($table); $values = $this->quoteArray(array_values($aValues)); $sql = "\n INSERT INTO {$table}\n "; if (CArray::isAssoc($aValues)) { $field = array_keys($aValues); foreach ($field as &$f) { $f = $this->quoteField($f); } $sql .= " (" . implode(", ", $field) . ")"; } $sql .= " VALUES (" . implode(", ", $values) . ")"; $this->query($sql); return $this->getLastInsertedId(); }