/** * Inserts a record into database. * * This method inserts a transient record in the database, and adds it * to the identity map of its correspondent table. It proxies to @see * processSingleInsert(), trigger insert hooks and validation of data * if required. * * @param Doctrine_Record $record * @return boolean false if record is not valid */ public function insert(Doctrine_Record $record) { $event = $record->invokeSaveHooks('pre', 'insert'); if ($record->isValid(false, false)) { $table = $record->getTable(); if (!$event->skipOperation) { if ($table->getOption('joinedParents')) { // just for bc! $this->_insertCTIRecord($table, $record); //-- } else { $this->processSingleInsert($record); } } $table->addRecord($record); $record->invokeSaveHooks('post', 'insert', $event); return true; } return false; }
/** * inserts a record into database * * @param Doctrine_Record $record record to be inserted * @return boolean */ public function insert(Doctrine_Record $record) { // listen the onPreInsert event $event = new Doctrine_Event($record, Doctrine_Event::RECORD_INSERT); $record->preInsert($event); $table = $record->getTable(); $table->getRecordListener()->preInsert($event); if ($record->isValid()) { if (!$event->skipOperation) { if ($table->getOption('joinedParents')) { // just for bc! $this->_insertCTIRecord($table, $record); //-- } else { $this->processSingleInsert($record); } } $table->addRecord($record); $table->getRecordListener()->postInsert($event); $record->postInsert($event); return true; } return false; }