cvs: pear /MDB2/MDB2/Wrapper peardb.php

From: Date: Thu, 29 Apr 2004 20:20:37 +0000
Subject: cvs: pear /MDB2/MDB2/Wrapper peardb.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-18978@lists.php.net to get a copy of this message
lsmith Thu Apr 29 16:20:37 2004 EDT Modified files: /pear/MDB2/MDB2/Wrapper peardb.php Log: - fixed countless issues now passed all but the following tests of the PEAR::DB test suite: sequences - due to the fact that I am not wrapping MDB2_Error objects prepare/execute - due to missing support for & and ! placeholder error mapping - was failing on the real DB as well .. transaction test - was failing on the real DB as well due to using MyISAM .. row limit - this one failed since the row counter is not increased by the offset fetchmode object - feature is missing in MDB2, but maybe I can add it without too much of a performance penalty due the fact that we now are using is_a() in isError() tableinfo - was failing on DB as well get - see fetchmode_object bug22328 - was failing on DB as well http://cvs.php.net/diff.php/pear/MDB2/MDB2/Wrapper/peardb.php?r1=1.6&r2=1.7&ty=u Index: pear/MDB2/MDB2/Wrapper/peardb.php diff -u pear/MDB2/MDB2/Wrapper/peardb.php:1.6 pear/MDB2/MDB2/Wrapper/peardb.php:1.7 --- pear/MDB2/MDB2/Wrapper/peardb.php:1.6 Sun Apr 25 06:05:30 2004 +++ pear/MDB2/MDB2/Wrapper/peardb.php Thu Apr 29 16:20:37 2004 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@backendmedia.com> | // +----------------------------------------------------------------------+ // -// $Id: peardb.php,v 1.6 2004/04/25 10:05:30 lsmith Exp $ +// $Id: peardb.php,v 1.7 2004/04/29 20:20:37 lsmith Exp $ // /** @@ -122,6 +122,15 @@ define('DB_TABLEINFO_ORDERTABLE', MDB2_TABLEINFO_ORDERTABLE); define('DB_TABLEINFO_FULL', MDB2_TABLEINFO_FULL); +define('DB_PORTABILITY_NONE', MDB2_PORTABILITY_NONE); +define('DB_PORTABILITY_LOWERCASE', MDB2_PORTABILITY_LOWERCASE); +define('DB_PORTABILITY_RTRIM', MDB2_PORTABILITY_RTRIM); +define('DB_PORTABILITY_DELETE_COUNT', MDB2_PORTABILITY_DELETE_COUNT); +define('DB_PORTABILITY_NUMROWS', MDB2_PORTABILITY_NUMROWS); +define('DB_PORTABILITY_ERRORS', MDB2_PORTABILITY_ERRORS); +define('DB_PORTABILITY_EMPTY_TO_NULL', MDB2_PORTABILITY_EMPTY_TO_NULL); +define('DB_PORTABILITY_ALL', MDB2_PORTABILITY_ALL); + /** * Wrapper that makes MDB2 behave like PEAR DB * @@ -217,7 +226,7 @@ * @category Database * @author Lukas Smith <smith@backendmedia.com> */ -class DB_result extends MDB2_Result +class DB_result extends MDB2_Result_Common { var $result; var $row_counter = null; @@ -231,6 +240,11 @@ $this->result = $result; } + function fetch() + { + return $this->result->fetch(); + } + function fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null) { return $this->result->fetchRow($fetchmode); @@ -275,7 +289,7 @@ function getRowCounter() { - return $this->result->rownum; + return $this->result->rownum+1; } } @@ -289,16 +303,20 @@ } } -class MDB2_PEARProxy +class MDB2_PEARProxy extends PEAR { var $MDB2_object; + var $phptype; + var $connection; function MDB2_PEARProxy(&$MDB2_object) { $this->MDB2_object =& $MDB2_object; -# $this->MDB2_object->PEAR('DB_Error'); + $this->PEAR('DB_Error'); $this->MDB2_object->setOption('seqname_col_name', 'id'); $this->MDB2_object->setOption('result_wrap_class', 'DB_result'); + $this->phptype = $this->MDB2_object->phptype; + $this->connection = $this->MDB2_object->connection; } function connect($dsninfo, $persistent = false) @@ -312,6 +330,11 @@ return $this->MDB2_object->disconnect(); } + function toString() + { + return $this->MDB2_object->__toString(); + } + function quoteString($string) { $string = $this->quote($string); @@ -329,6 +352,29 @@ return "'".$this->MDB2_object->quote($string)."'"; } + function escapeSimple($str) + { + return $this->MDB2_object->escape($str); + } + + function quoteSmart($in) + { + if (is_int($in) || is_double($in)) { + return $in; + } elseif (is_bool($in)) { + return $in ? 1 : 0; + } elseif (is_null($in)) { + return 'NULL'; + } else { + return "'" . $this->escapeSimple($in) . "'"; + } + } + + function quoteIdentifier($string) + { + return $this->MDB2_object->quoteIdentifier($string); + } + // map? function provides($feature) { @@ -414,6 +460,9 @@ if (MDB2::isError($sth)) { return $sth; } + if (!is_array($params)) { + $params = array($params); + } $return =& $this->MDB2_object->executeParams($sth, null, $params); return $return; } else { @@ -431,10 +480,13 @@ } } - function limitQuery($query, $from, $count) + function limitQuery($query, $from, $count, $params = array()) { - $this->MDB2_object->loadModule('extended'); - $result =& $this->MDB2_object->extended->limitQuery($query, null, $from, $count); + $result = $this->MDB2_object->setLimit($count, $from); + if (MDB2::isError($result)) { + return $result; + } + $result =& $this->query($query, $params); return $result; } @@ -540,6 +592,11 @@ $arr = $result->fetchRow($fetchmode); } + function freePrepared($prepared) + { + return $this->MDB2_object->freePrepared($prepared); + } + function freeResult($result) { $result = $this->_wrapResource($result);

« previous php.pear.cvs (#18978) next »