Re: PEAR::DB, function &limitQuery() modification

From: Date: Fri, 07 Feb 2003 20:59:41 +0000
Subject: Re: PEAR::DB, function &limitQuery() modification
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-13055@lists.php.net to get a copy of this message
> Hi, > > This change looks good, with one exception: is_a() exists only in 4.2.0 > or later, which is not a dependency I want to introduce to DB. > get_class() would work just fine here. I guess it would, except that the limitQuery() function written as is should be overloaded for descendants of DB_commom using a subclass of DB_result. I don't know if any exists in an application using the limitQuery () function, but otherwise this modification could rise a compatiblity issue... > But beyond that, aren't you missing the case where query() returns DB_OK? Anyway, i've made the modifications ton handle both a DB_OK return value from the query() function and and the compatibility with PHP versions prior to 4.2. Here is the new source code for the function : // {{{ limitQuery() /** * Generates a limited query * *EXPERIMENTAL* * * @param string $query query or statement to prepare * @param integer $from the row to start to fetching * @param integer $count the numbers of rows to fetch * @param Array $params required for a statement * * @return mixed a DB_Result object, DB_OK or a DB_Error * * @access public */ function &limitQuery($query, $from, $count, $params = array()) { $query = $this->modifyLimitQuery($query, $from, $count); $result = $this->query($query, $params); if (DB::isError($result) || get_class($result) == "db_result" || $result = DB_OK) { return $result; } else { $options['limit_from'] = $from; $options['limit_count'] = $count; return new DB_result($this, $result, $options); } } // }}}

« previous php.pear.dev (#13055) next »