From: K. O. <on...@xo...> - 2003-06-06 03:25:59
|
Hi, Did you have problem using the criteria class? Thanks and regards, K. Ono ---------------------------------------------------------------------------- - /** * load objects from database * * Note: doesn't use Criteria because that class needs a WHERE clause * * @param int $limit * @param int $start * @param bool $id_as_key should the ID be used as the array key? * @param string $sql_clause arbitrary where/order by clause (overrides default sorting) * @return array array of references to objects */ function &fetch($limit=0, $start=0, $id_as_key=false, $sql_clause=null) { $objects = array(); $limit = $start = 0; $sql = 'SELECT * FROM '.$this->table; if ($sql_clause) { $sql .= ' '.$sql_clause; } else { if ($this->sort) { // could do caching of ORDER BY clause $sql .= ' ORDER BY '; $scnt = count($this->sort); for ($i=0; $i < $scnt; $i++) { $sql .= $this->sort[$i].' '.$this->sortOrder[$i]; if ($i+1 < $scnt) $sql .= ', '; } } } $result = $this->db->query($sql, $limit, $start); if (!$result) { return $objects; } while ($myrow = $this->db->fetchArray($result)) { $object = new $this->class(); $object->assignVars($myrow); if (!$id_as_key) { $objects[] =& $object; } else { $objects[$myrow[$this->id]] =& $object; } unset($object); } return $objects; } -------------------------------------------------------------------------- |
From: Martin K. <Mar...@bl...> - 2003-06-06 06:43:34
|
"K. Ono" <on...@xo...> writes on Fri, 06 Jun 2003 05:22:59 +0200 (METDST): > Hi, > > Did you have problem using the criteria class? Not in a real use. I have had a look at the class(es) itself/themselves and browsed a few occurences where it is in use. So perhaps I am missing something. What I wanted to do is: Set a limit (or start and limit) by itself (no where clause). I didn't see a way to achieve this, so I did fetch() this way. I also wasn't sure if I could add multiple sort columns (with separate sort order). Or how to use multiple group by columns. I need some time to play with the class. Regards, Masi |
From: K. O. <on...@xo...> - 2003-06-08 02:43:50
|
> Set a limit (or start and limit) by itself (no where clause). I didn't see a way to achieve this, so I did fetch() this way. Yes, you can set it without the where part by creating an instance of the CriteriaCompo class that doesn't contain any child instance of the Criteria class. $criteria = new CriteriaCompo(); $criteria->setLimit(10); $criteria->setStart(5); With the above code, either $criteria->renderWhere() or $criteria->render() will return an empty string. > I also wasn't sure if I could add multiple sort columns (with separate sort order). Or how to use multiple group by columns. I need some time to play with the class. You're right and this is not currently possible. You can only set multiple sort columns. $criteria->setSort('id, title'); - Kazu |
From: Martin K. <Mar...@bl...> - 2003-06-10 15:19:58
|
"K. Ono" <on...@xo...> writes on Sun, 08 Jun 2003 04:42:35 +0200 (METDST): > > > Set a limit (or start and limit) by itself (no where clause). I > > didn't see > a way to achieve this, so I did fetch() this way. > > Yes, you can set it without the where part by creating an instance of > the CriteriaCompo class > that doesn't contain any child instance of the Criteria class. > > $criteria = new CriteriaCompo(); > $criteria->setLimit(10); > $criteria->setStart(5); > With the above code, either $criteria->renderWhere() or > $criteria->render() > will return an empty string. Ok, so we don't need a fetch() method like this. But I'd like to have a default sorting for the class. We could either let my extended constructor like it is (with sort ahnd sort order arguments) or remove them but retain the methods to set them explicitely. Or we could change the whole mechanism to a default Criteria object (again with the choices of constructor argument and/or method). Should Criteria move to class if ObjectHandler depends on it (though indirectly). > > I also wasn't sure if I could add multiple sort columns (with > > separate sort order). Or how to use multiple group by columns. I > > need some time to play with the class. > > You're right and this is not currently possible. You can only set > multiple sort columns. > $criteria->setSort('id, title'); BTW, you cannot change the sort order after changing it from the default. Masi PS: How can some general info for a class/file be added to the documtation. I know how it works in Doxygen and would like to add some lines of tipps and tricks for Object and Criteria. That is, if I find the time ;-) |
From: R. M. v. D. <mv...@ca...> - 2003-06-06 21:52:00
|
Hello, I was just wondering if someone could quickly let me know a few stats of the xoops.org site. I am trying to help someone who is getting an 'out of memory' error with an 8M limit (php.ini) while loading a user administration page (just over 700 users). This seems odd for such a small number of users, so I am just wondering what the xoops.org setup is (same 8M limit?), and how many users there are. I assume there are no bugs on the 'Edit User' page from System Administration?? While I'm at it... any of you guys know a good way from PHP to show the amount of memory being used by a script? I couldn't find any functions, but maybe I'm just blind. :-) Thanks very much, Mike |
From: K. O. <on...@xo...> - 2003-06-08 02:43:51
|
> I was just wondering if someone could quickly let me know a few stats of > the xoops.org site. I am trying to help someone who is getting an 'out of > memory' error with an 8M limit (php.ini) while loading a user > administration page (just over 700 users). The xoops.org site is using the default setting of php.ini included in 4.3.1 but with register_globals turned on. So far, I haven't experienced any error like that yet on the site.. I had some users complain about this before, but those people had a very large site with thousands of registered users, and was using an old version of XOOPS which did not have paging capability in the 'Edit groups' page. - Kazu |