Ticket #579: 579-jDaoConditions-group.diff
| File 579-jDaoConditions-group.diff, 2.0 kB (added by thomas, 4 months ago) |
|---|
-
lib/jelix/dao/jDaoConditions.class.php
old new 64 64 public $order = array (); 65 65 66 66 /** 67 * the groups we wants the list to be 68 */ 69 public $group = array (); 70 71 /** 67 72 * the condition we actually are browsing 68 73 */ 69 74 private $_currentCondition; … … 86 91 } 87 92 88 93 /** 94 * add a group clause 95 * 96 * @param string $field_id the property name used to group results 97 */ 98 function addItemGroup($field_id) { 99 $this->group[] = $field_id; 100 } 101 102 /** 89 103 * says if there are no conditions nor order 90 104 * @return boolean false if there isn't condition 91 105 */ -
lib/jelix/dao/jDaoFactoryBase.class.php
old new 242 242 $query .= ($this->_whereClause !='' ? ' AND ' : ' WHERE '); 243 243 $query .= $this->_createConditionsClause($searchcond); 244 244 } 245 $query.= $this->_createGroupClause($searchcond); 245 246 $query.= $this->_createOrderClause($searchcond); 246 247 247 248 if($limitCount != 0){ … … 342 343 } 343 344 344 345 /** 346 * @internal 347 */ 348 final protected function _createGroupClause($daocond) { 349 $group = array (); 350 $props = $this->getProperties(); 351 foreach ($daocond->group as $name) { 352 if (isset($props[$name])) { 353 $group[] = $name; 354 } 355 } 356 357 if (count ($group)) { 358 return ' GROUP BY '.implode(', ', $group); 359 } 360 return ''; 361 } 362 363 /** 345 364 * @internal it don't support isExpr property of a condition because of security issue (SQL injection) 346 365 * because the value could be provided by a form, it is escaped in any case 347 366 */
