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

From: Date: Fri, 07 Feb 2003 20:20:29 +0000
Subject: Re: PEAR::DB, function &limitQuery() modification
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-13054@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. But beyond that, aren't you missing the case where query() returns DB_OK? I will release 1.4 including this change when this is sorted out. - Stig On Fri, 7 Feb 2003, Antoine Angénieux wrote: > Hello, > > I'm using the experimental implementation of limitQuery() in a project. > It works fine with the three databases our project supports : Oracle, > MySql and postgreSql ! > > The thing is it is the only query operation that does not work with > statements, on the contrary of DB::query(), etc... > > Thus I modified a litte bit the code of the limitQuery in the common.php > script in order to have it work with queries as well as with statements. > > Here is a cvs diff between the repository's version of common.php and my > modified script : > diff -r1.12 common.php > > 750c750 > < * @param string $query query > --- > > * @param string $query query or statement to prepare > 752a753 > > * @param Array $params required for a statement > 758c759 > < function &limitQuery($query, $from, $count) > --- > > function &limitQuery($query, $from, $count, $params = array()) > 761,762c762,763 > < $result = $this->simpleQuery($query); > < if (DB::isError($result) || $result === DB_OK) { > --- > > $result = $this->query($query, $params); > > if (DB::isError($result) || is_a($result, "db_result")) { > > And here is the source code of the modified 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 (optional) $params required for a statement > * > * @return mixed a DB_Result object 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) || is_a($result, "db_result")) { > return $result; > } else { > $options['limit_from'] = $from; > $options['limit_count'] = $count; > return new DB_result($this, $result, $options); > } > } > > // }}} > > Do you think this modification could be added directly to the PEAR::DB > package? > > If you think so, I can send you my updated version of common.php > > Thank you in advance, > > Antoine. > >

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