/** * Insert a new record and get the value of the primary key. * * @param array $values * @param string $sequence * @return int */ public function insertGetId(array $values, $sequence = null) { $sql = $this->grammar->compileInsertGetId($this, $values, $sequence); $values = $this->cleanBindings($values); $this->connection->query($sql, $values); $id = is_null($sequence) ? $this->connection->lastInsertId() : $this->connection->lastInsertId($sequence); return is_numeric($id) ? (int) $id : $id; }