Ejemplo n.º 1
0
 /**
  * delete all record corresponding to the conditions stored into the
  * jDaoConditions object.
  * @param jDaoConditions $searchcond
  * @return number of deleted rows
  * @since 1.0beta3
  */
 public final function deleteBy($searchcond)
 {
     if ($searchcond->isEmpty()) {
         return 0;
     }
     $query = 'DELETE FROM ' . $this->_conn->encloseName($this->_tables[$this->_primaryTable]['realname']) . ' WHERE ';
     $query .= $this->_createConditionsClause($searchcond, false);
     if ($this->_deleteByBeforeEvent) {
         jEvent::notify("daoDeleteByBefore", array('dao' => $this->_daoSelector, 'criterias' => $searchcond));
     }
     $result = $this->_conn->exec($query);
     if ($this->_deleteByAfterEvent) {
         jEvent::notify("daoDeleteByAfter", array('dao' => $this->_daoSelector, 'criterias' => $searchcond, 'result' => $result));
     }
     return $result;
 }
Ejemplo n.º 2
0
 function testNonEmptyRecursive()
 {
     $cond = new jDaoConditions();
     $cond->startGroup();
     $cond->startGroup('OR');
     $cond->addCondition('test', '=', 1);
     $cond->endGroup();
     $cond->endGroup();
     $this->assertTrue($cond->hasConditions());
     $this->assertFalse($cond->isEmpty());
 }