protected function _prepareTpl() { $dao = jDao::get('config'); $this->_tpl->assign('config', $dao->findAll()); $this->_tpl->assign('oneconf', $dao->get('foo')); $this->_tpl->assign('nombre', $dao->countAll()); $this->_tpl->assign('nombrevalue', $dao->getCountValue()); $cond = new jDaoConditions('or'); $cond->addCondition('ckey', '=', 'foo'); $cond->addCondition('ckey', '=', 'bar'); $this->_tpl->assign('petitconfig', $dao->findBy($cond)); }
/** * overload this method if you wan to do additionnal conditions to the index's select * during the index action. * @param jDaoConditions $cond the conditions */ protected function _indexSetConditions($cond) { $keyActionDao = $this->_getAction($this->dao); if (isset($_SESSION['CRUD_LISTORDER'][$keyActionDao])) { $itemsOrder = $_SESSION['CRUD_LISTORDER'][$keyActionDao]; } else { $itemsOrder = $this->propertiesForRecordsOrder; } foreach ($itemsOrder as $p => $order) { if ($order == '') { continue; } $cond->addItemOrder($p, $order); } }
/** * overload this method if you wan to do additionnal conditions to the index's select * during the index action. * @param jDaoConditions $cond the conditions */ protected function _indexSetConditions($cond) { foreach ($this->propertiesForRecordsOrder as $p => $order) { $cond->addItemOrder($p, $order); } }
/** * 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; }
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()); }