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

From: Date: Sat, 08 Feb 2003 09:24:11 +0000
Subject: Re: PEAR::DB, function &limitQuery() modification
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-13067@lists.php.net to get a copy of this message
Hi, DB 1.4b1 is out, including this patch. Please try it and let me know if there are any problems. - 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 (#13067) next »