/**
  * Test the doInsert() method when passed a generated object.
  */
 public function testDoInsert_Obj()
 {
     $name = "A Sample Publisher - " . time();
     $values = new Publisher();
     $values->setName($name);
     PublisherPeer::doInsert($values);
     $c = new Criteria();
     $c->add(PublisherPeer::NAME, $name);
     $matches = PublisherPeer::doSelect($c);
     $this->assertEquals(1, count($matches), "Expect there to be exactly 1 publisher just-inserted.");
     $this->assertTrue(1 != $matches[0]->getId(), "Expected to have different ID than one put in values Criteria.");
 }
Exemple #2
0
 protected function doSave($con)
 {
     $affectedRows = 0;
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = PublisherPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 $this->setId($pk);
                 $this->setNew(false);
             } else {
                 $affectedRows += PublisherPeer::doUpdate($this, $con);
             }
             $this->resetModified();
         }
         if ($this->collCatalogs !== null) {
             foreach ($this->collCatalogs as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }