/**
  * 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);
     }
 }
Ejemplo n.º 2
0
 /**
  * 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);
     }
 }
Ejemplo n.º 3
0
 function testConditions()
 {
     try {
         $cond = new jDaoConditions();
         $check = '<?xml version="1.0"?>
         <object class="jDaoConditions">
             <array p="order">array()</array>
             <boolean m="isEmpty()" value="true" />
             <object p="condition" class="jDaoCondition">
                 <null p="parent" />
                 <array p="conditions">array()</array>
                 <array p="group">array()</array>
                 <string p="glueOp" value="AND"/>
             </object>
         </object>';
         $this->assertComplexIdenticalStr($cond, $check);
         $cond = new jDaoConditions();
         $cond->addItemOrder('foo', 'DESC');
         $check = '<?xml version="1.0"?>
         <object class="jDaoConditions">
             <array p="order">array("foo"=>"DESC")</array>
             <boolean m="isEmpty()" value="false" />
             <object p="condition" class="jDaoCondition">
                 <null p="parent" />
                 <array p="conditions">array()</array>
                 <array p="group">array()</array>
                 <string p="glueOp" value="AND"/>
             </object>
         </object>';
         $this->assertComplexIdenticalStr($cond, $check);
         $cond = new jDaoConditions();
         $cond->addCondition('foo', '=', 'toto', false);
         $check = '<?xml version="1.0"?>
         <object class="jDaoConditions">
             <array p="order">array()</array>
             <boolean m="isEmpty()" value="false" />
             <object p="condition" class="jDaoCondition">
                 <null p="parent" />
                 <array p="conditions">array(array("field_id"=>"foo","value"=>"toto", "operator"=>"=", "isExpr"=>false))</array>
                 <array p="group">array()</array>
                 <string p="glueOp" value="AND"/>
             </object>
         </object>';
         $this->assertComplexIdenticalStr($cond, $check);
         $cond->startGroup('OR');
         $cond->addCondition('foo1', '<', '100');
         $cond->addCondition('foo1', '>', '0');
         $cond->endGroup();
         $check = '<?xml version="1.0"?>
         <object class="jDaoConditions">
             <array p="order">array()</array>
             <boolean m="isEmpty()" value="false" />
             <object p="condition" class="jDaoCondition">
                 <null p="parent" />
                 <array p="conditions">array(array("field_id"=>"foo","value"=>"toto", "operator"=>"=", "isExpr"=>false))</array>
                 <array p="group">
                     <object p="condition" class="jDaoCondition">
                         <object p="parent" class="jDaoCondition" />
                         <array p="conditions">array(
                          array("field_id"=>"foo1","value"=>"100", "operator"=>"&lt;", "isExpr"=>false),
                          array("field_id"=>"foo1","value"=>"0", "operator"=>"&gt;", "isExpr"=>false))</array>
                         <array p="group">array()</array>
                         <string p="glueOp" value="OR"/>
                     </object>
                 </array>
                 <string p="glueOp" value="AND"/>
             </object>
         </object>';
         $this->assertComplexIdenticalStr($cond, $check);
     } catch (jDaoXmlException $e) {
         $this->fail("Exception sur le contenu xml inattendue : " . $e->getMessage() . ' (' . $e->getLocaleKey() . ')');
     } catch (Exception $e) {
         $this->fail("Exception inconnue : " . $e->getMessage());
     }
 }