isValid() public method

tests validity of the record using the current data.
public isValid ( boolean $deep = false, boolean $hooks = true ) : boolean
$deep boolean run the validation process on the relations
$hooks boolean invoke save hooks before start
return boolean whether or not this record is valid
Example #1
0
 /**
  * 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;
 }
Example #2
0
 /**
  * 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;
 }