PEAR::DB, function &limitQuery() modification

From: Date: Fri, 07 Feb 2003 14:27:56 +0000
Subject: PEAR::DB, function &limitQuery() modification
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-13048@lists.php.net to get a copy of this message
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. -- Antoine ANGENIEUX http://www.clever-age.com Clever Age - conseil en architecture technique GSM: +33 6 63 58 36 95 Tél: +33 1 49 01 28 63

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