Example #1
0
 /**
  * Delete this dataset (remove the corresponding row from the table). 
  * Does nothing in this default implementation and may be overridden 
  * in subclasses where it makes sense.
  *
  * @return  int affected rows
  * @throws  rdbms.SQLException
  */
 public function delete()
 {
     $peer = $this->getPeer();
     if (empty($peer->primary)) {
         throw new SQLStateException('No primary key for table ' . $peer->getTable());
     }
     $criteria = new Criteria();
     foreach ($peer->primary as $key) {
         $criteria->add($key, $this->{$key}, EQUAL);
     }
     $affected = $peer->doDelete($criteria);
     $this->_changed = [];
     return $affected;
 }
 public function testIsJoin()
 {
     $crit = new Criteria();
     $this->assertFalse($crit->isJoin());
     $this->assertTrue($crit->setFetchmode(\rdbms\join\Fetchmode::join('PersonJob'))->isJoin());
     $crit->fetchmode = array();
     $this->assertFalse($crit->isJoin());
     $this->assertFalse($crit->setFetchmode(\rdbms\join\Fetchmode::select('PersonJob'))->isJoin());
 }
 function withProjectionTest()
 {
     $crit = new Criteria();
     $this->assertInstanceOf('rdbms.Criteria', $crit->withProjection(Projections::property(Job::column('job_id'))));
     $this->assertFalse($crit->isProjection());
     $this->assertTrue($crit->withProjection(Projections::property(Job::column('job_id')))->isProjection());
 }