public function getLastInsertID() { foreach ($this->getTableInfo()->getColumns() as $column) { if ($column->hasSequence()) { $command = $this->getDbConnection()->createCommand('SELECT @@Identity'); return intval($command->queryScalar()); } } }