Changeset 1007
- Timestamp:
- 07/08/08 14:35:17 (1 month ago)
- Files:
-
- trunk/lib/jelix/CREDITS (modified) (1 diff)
- trunk/lib/jelix/dao/jDaoFactoryBase.class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/jelix/CREDITS
r1006 r1007 163 163 Thomas 164 164 - fixed bugs in jDao (#576, #643) 165 - jDaoFactoryBase::countBy : allowing to do count on distinct fields (#580) 165 166 166 167 Christian Tritten trunk/lib/jelix/dao/jDaoFactoryBase.class.php
r1006 r1007 263 263 * @return int the count 264 264 */ 265 final public function countBy($searchcond) { 266 $query = 'SELECT COUNT(*) as c '.$this->_fromClause.$this->_whereClause; 265 final public function countBy($searchcond, $distinct=null) { 266 $count = '*'; 267 if ($distinct !== null) { 268 $props = $this->getProperties(); 269 if (isset($props[$distinct])) 270 $count = 'DISTINCT '.$this->_tables[$props[$distinct]['table']]['realname'].'.'.$props[$distinct]['fieldName']; 271 } 272 273 $query = 'SELECT COUNT('.$count.') as c '.$this->_fromClause.$this->_whereClause; 267 274 if ($searchcond->hasConditions ()){ 268 275 $query .= ($this->_whereClause !='' ? ' AND ' : ' WHERE ');
