Changeset 1137
- Timestamp:
- 10/28/08 16:45:02 (2 months ago)
- Files:
-
- branches/1.0.x/lib/jelix/CREDITS (modified) (3 diffs)
- branches/1.0.x/lib/jelix/dao/jDaoConditions.class.php (modified) (5 diffs)
- branches/1.0.x/testapp/modules/jelix_tests/tests/jdao.conditions.html_cli.php (modified) (1 diff)
- trunk/lib/jelix/CREDITS (modified) (1 diff)
- trunk/lib/jelix/dao/jDaoConditions.class.php (modified) (7 diffs)
- trunk/testapp/modules/jelix_tests/tests/jdao.conditions.html_cli.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.0.x/lib/jelix/CREDITS
r1106 r1137 24 24 Vincent Bonnard 25 25 - bug fix in jXmlRpc.class.php (#190) 26 26 27 27 Cedric 28 28 - bug fix in jFile::read … … 81 81 - fixes about table_prefix in jDb (#702, #703) 82 82 - jTcpdf: added default font for header and footer (#693) 83 - jDao: autoremove of empty groups in jDaoConditions (#724) 83 84 84 85 Bastien Jaillot (aka bastnic) … … 98 99 Nicolas Lassalle 99 100 - bug fix in jResponseBinary (#188) 100 101 101 102 Yannick Le Guédart (aka Torgan) 102 103 - auth driver: jAuthDriverClass branches/1.0.x/lib/jelix/dao/jDaoConditions.class.php
r727 r1137 4 4 * @subpackage dao 5 5 * @author Croes Gérald, Laurent Jouanneau 6 * @contributor Laurent Jouanneau 6 * @contributor Laurent Jouanneau, Julien Issler 7 7 * @copyright 2001-2005 CopixTeam, 2005-2006 Laurent Jouanneau 8 * @copyright 2008 Julien Issler 8 9 * This classes was get originally from the Copix project (CopixDAOSearchConditions, Copix 2.3dev20050901, http://www.copix.org) 9 10 * Some lines of code are copyrighted 2001-2005 CopixTeam (LGPL licence). … … 45 46 $this->parent = $parent; 46 47 $this->glueOp = $glueOp; 48 } 49 50 public function isEmpty(){ 51 return empty($this->conditions) && empty($this->group); 47 52 } 48 53 } … … 111 116 function startGroup ($glueOp = 'AND'){ 112 117 $cond= new jDaoCondition ($glueOp, $this->_currentCondition); 113 $this->_currentCondition->group[] = $cond;114 118 $this->_currentCondition = $cond; 115 119 } … … 120 124 function endGroup (){ 121 125 if ($this->_currentCondition->parent !== null){ 126 if(!$this->_currentCondition->isEmpty()) 127 $this->_currentCondition->parent->group[] = $this->_currentCondition; 122 128 $this->_currentCondition = $this->_currentCondition->parent; 123 129 } … … 138 144 } 139 145 } 140 ?>branches/1.0.x/testapp/modules/jelix_tests/tests/jdao.conditions.html_cli.php
r851 r1137 106 106 } 107 107 108 function testEmptyRecursive(){ 109 $cond = new jDaoConditions(); 110 $cond->startGroup(); 111 $cond->startGroup('OR'); 112 $cond->endGroup(); 113 $cond->endGroup(); 114 $this->assertFalse($cond->hasConditions()); 115 $this->assertTrue($cond->isEmpty()); 116 } 108 117 109 118 function testNonEmptyRecursive(){ 119 $cond = new jDaoConditions(); 120 $cond->startGroup(); 121 $cond->startGroup('OR'); 122 $cond->addCondition('test','=',1); 123 $cond->endGroup(); 124 $cond->endGroup(); 125 $this->assertTrue($cond->hasConditions()); 126 $this->assertFalse($cond->isEmpty()); 127 } 110 128 } 111 112 113 ?>trunk/lib/jelix/CREDITS
r1130 r1137 37 37 - jForms: radiobutton with value 0 should not get selected by default (#691) 38 38 - jTcpdf: added default font for header and footer (#693) 39 - jDao: autoremove of empty groups in jDaoConditions (#724) 39 40 40 41 Bastien Jaillot (aka bastnic) trunk/lib/jelix/dao/jDaoConditions.class.php
r1026 r1137 4 4 * @subpackage dao 5 5 * @author Croes Gérald, Laurent Jouanneau 6 * @contributor Laurent Jouanneau 6 * @contributor Laurent Jouanneau, Julien Issler 7 7 * @copyright 2001-2005 CopixTeam, 2005-2006 Laurent Jouanneau 8 8 * @copyright 2008 Thomas 9 * @copyright 2008 Julien Issler 9 10 * This classes was get originally from the Copix project (CopixDAOSearchConditions, Copix 2.3dev20050901, http://www.copix.org) 10 11 * Some lines of code are copyrighted 2001-2005 CopixTeam (LGPL licence). … … 47 48 $this->glueOp = $glueOp; 48 49 } 50 51 public function isEmpty(){ 52 return empty($this->conditions) && empty($this->group); 53 } 49 54 } 50 55 … … 69 74 */ 70 75 public $group = array (); 71 76 72 77 /** 73 78 * the condition we actually are browsing … … 100 105 $this->group[] = $field_id; 101 106 } 102 107 103 108 /** 104 109 * says if there are no conditions nor order … … 126 131 function startGroup ($glueOp = 'AND'){ 127 132 $cond= new jDaoCondition ($glueOp, $this->_currentCondition); 128 $this->_currentCondition->group[] = $cond;129 133 $this->_currentCondition = $cond; 130 134 } … … 135 139 function endGroup (){ 136 140 if ($this->_currentCondition->parent !== null){ 141 if(!$this->_currentCondition->isEmpty()) 142 $this->_currentCondition->parent->group[] = $this->_currentCondition; 137 143 $this->_currentCondition = $this->_currentCondition->parent; 138 144 } … … 153 159 } 154 160 } 155 trunk/testapp/modules/jelix_tests/tests/jdao.conditions.html_cli.php
r815 r1137 4 4 * @subpackage jelix_tests module 5 5 * @author Jouanneau Laurent 6 * @contributor 6 * @contributor Julien Issler 7 7 * @copyright 2006-2007 Jouanneau laurent 8 * @copyright 2008 Julien Issler 8 9 * @link http://www.jelix.org 9 10 * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html … … 106 107 } 107 108 109 function testEmptyRecursive(){ 110 $cond = new jDaoConditions(); 111 $cond->startGroup(); 112 $cond->startGroup('OR'); 113 $cond->endGroup(); 114 $cond->endGroup(); 115 $this->assertFalse($cond->hasConditions()); 116 $this->assertTrue($cond->isEmpty()); 117 } 108 118 109 119 function testNonEmptyRecursive(){ 120 $cond = new jDaoConditions(); 121 $cond->startGroup(); 122 $cond->startGroup('OR'); 123 $cond->addCondition('test','=',1); 124 $cond->endGroup(); 125 $cond->endGroup(); 126 $this->assertTrue($cond->hasConditions()); 127 $this->assertFalse($cond->isEmpty()); 128 } 110 129 } 111 112 113 ?>
