Changeset 1015
- Timestamp:
- 07/11/08 23:53:07 (2 months ago)
- Files:
-
- trunk/lib/jelix/CREDITS (modified) (1 diff)
- trunk/lib/jelix/dao/jDaoConditions.class.php (modified) (3 diffs)
- trunk/lib/jelix/dao/jDaoFactoryBase.class.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/jelix/CREDITS
r1014 r1015 166 166 - fixed bugs in jDao (#576, #643) 167 167 - jDaoFactoryBase::countBy : allowing to do count on distinct fields (#580) 168 - JDaoConditions::addItemGroup : add clause group by (#579) 168 169 169 170 Christian Tritten trunk/lib/jelix/dao/jDaoConditions.class.php
r727 r1015 6 6 * @contributor Laurent Jouanneau 7 7 * @copyright 2001-2005 CopixTeam, 2005-2006 Laurent Jouanneau 8 * @copyright 2008 Thomas 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). … … 65 66 66 67 /** 68 * the groups we wants the list to be 69 */ 70 public $group = array (); 71 72 /** 67 73 * the condition we actually are browsing 68 74 */ … … 86 92 } 87 93 94 /** 95 * add a group clause 96 * 97 * @param string $field_id the property name used to group results 98 */ 99 function addItemGroup($field_id) { 100 $this->group[] = $field_id; 101 } 102 88 103 /** 89 104 * says if there are no conditions nor order trunk/lib/jelix/dao/jDaoFactoryBase.class.php
r1007 r1015 9 9 * @copyright 2007 Loic Mathaud 10 10 * @copyright 2007 Julien Issler 11 * @copyright 2008 Thomas 11 12 * @link http://www.jelix.org 12 13 * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file … … 243 244 $query .= $this->_createConditionsClause($searchcond); 244 245 } 246 $query.= $this->_createGroupClause($searchcond); 245 247 $query.= $this->_createOrderClause($searchcond); 246 248 … … 349 351 } 350 352 353 /** 354 * @internal 355 */ 356 final protected function _createGroupClause($daocond) { 357 $group = array (); 358 $props = $this->getProperties(); 359 foreach ($daocond->group as $name) { 360 if (isset($props[$name])) { 361 $group[] = $name; 362 } 363 } 364 365 if (count ($group)) { 366 return ' GROUP BY '.implode(', ', $group); 367 } 368 return ''; 369 } 370 351 371 /** 352 372 * @internal it don't support isExpr property of a condition because of security issue (SQL injection)
