/** * Creates a new persisted instance of activerecord (Inserts a new record to a database) * * @return int Rows affected */ protected function insert() { $insertQuery = "INSERT INTO " . $this->schema->getName() . " SET " . $this->enumerateModifiedFields(); $result = $this->executeUpdate($insertQuery); // get inserted record ID if (count($this->schema->getPrimaryKeyList()) == 1) { $PKList = $this->schema->getPrimaryKeyList(); $PKField = $PKList[key($PKList)]; if ($PKField->getDataType() instanceof ARInteger && !$this->getID()) { $IDG = $this->db->getIdGenerator(); $this->setID($IDG->getId(), false); } } $this->storeToPool(); $this->resetModifiedStatus(); return $result; }