function testComplexChaining() { $a = new lmbSQLCriteria('a'); $b = new lmbSQLCriteria('b'); $c = new lmbSQLCriteria('c'); $d = new lmbSQLCriteria('d'); $e = new lmbSQLCriteria('e'); $g = new lmbSQLCriteria('g'); $h = new lmbSQLCriteria('h'); $a->addOr($b->addAnd($c))->addAnd($d->addOr($e)->addAnd($g->addOr($h))); $this->assertEqual($a->toStatementString(), 'a OR (b AND c) AND (d OR e AND (g OR h))'); }
function doDisplay() { if (!($id = $this->request->getInteger('id'))) { $this->is_root = true; $criteria = new lmbSQLCriteria('parent_id > 0'); $criteria->addAnd(new lmbSQLCriteria('level = 1')); $this->item = lmbCmsDocument::findRoot(); } else { $this->is_root = false; if (!($this->item = $this->_getObjectByRequestedId())) { return $this->forwardTo404(); } $criteria = new lmbSQLCriteria('parent_id = ' . $this->item->getId()); } $this->items = lmbActiveRecord::find($this->_object_class_name, array('criteria' => $criteria, 'sort' => array('priority' => 'ASC'))); $this->_applySortParams(); }
function remove($object) { $table = new lmbTableGateway($this->relation_info['table'], $this->conn); $criteria = new lmbSQLCriteria(); $criteria->addAnd(lmbSQLCriteria::equal($this->relation_info['field'], $this->owner->getId())); $criteria->addAnd(lmbSQLCriteria::equal($this->relation_info['foreign_field'], $object->getId())); $table->delete($criteria); $this->reset(); }