cvs: pear /MDB pear_wrapper.php

From: Date: Thu, 16 May 2002 19:28:03 +0000
Subject: cvs: pear /MDB pear_wrapper.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-3868@lists.php.net to get a copy of this message
lsmith Thu May 16 15:28:03 2002 EDT Modified files: /pear/MDB pear_wrapper.php Log: some cleanups to the factory and connect method

Index: pear/MDB/pear_wrapper.php diff -u pear/MDB/pear_wrapper.php:1.2 pear/MDB/pear_wrapper.php:1.3 --- pear/MDB/pear_wrapper.php:1.2 Thu May 2 12:23:25 2002 +++ pear/MDB/pear_wrapper.php Thu May 16 15:28:02 2002 @@ -1,7 +1,7 @@ <?php /* * - * @(#) $Header: /usr/repository/pear/MDB/pear_wrapper.php,v 1.2 2002/05/02 16:23:25 lsmith Exp $ + * @(#) $Header: /usr/repository/pear/MDB/pear_wrapper.php,v 1.3 2002/05/16 19:28:02 lsmith Exp $ * */ @@ -11,22 +11,18 @@ { function &factory($type) { - $db = MDB::factory($type); - if(PEAR::isError($db)) - { - return $MDB_object; - } - $obj =& new MDB_PEAR_PROXY($db); - return $obj; + return MDB::factory($type); } function &connect($dsn, $options = false) { - $db = MDB::connect($dsn, $options); - $MDB_object = MDB::connect($dsn, $options); - if(PEAR::isError($MDB_object)) + if (!is_array($options) && $options) { + $$options["persistent"] = true; + } + $db = MDB::connect($dsn, $options); + if(PEAR::isError($db)) { - return $MDB_object; + return $db; } $obj =& new MDB_PEAR_PROXY($db); return $obj; @@ -112,18 +108,18 @@ function fetchRow($fetchmode = DB_FETCHMODE_DEFAULT, $rownum = null) { - $this->dbh->fetchInto($this->result, &$arr, $fetchmode, $rownum); - if(is_array($arr)) { - return $arr; - } - else { - return null; - } + $this->dbh->fetchInto($this->result, &$arr, $fetchmode, $rownum); + if(is_array($arr)) { + return $arr; + } + else { + return null; + } } function fetchInto(&$arr, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum = null) { - $this->dbh->fetchInto($this->result, &$arr, $fetchmode, $rownum); + $this->dbh->fetchInto($this->result, &$arr, $fetchmode, $rownum); } function numCols() @@ -174,204 +170,204 @@ class MDB_PEAR_PROXY { - var $MDB_object; - - function MDB_PEAR_PROXY($MDB_object) - { - $this->MDB_object = $MDB_object; - } + var $MDB_object; + + function MDB_PEAR_PROXY($MDB_object) + { + $this->MDB_object = $MDB_object; + } function connect($dsninfo, $persistent = false) { - return $this->MDB_object->connect($dsninfo, $persistent); + return $this->MDB_object->connect($dsninfo, $persistent); } function disconnect() { - return $this->MDB_object->disconnect(); + return $this->MDB_object->disconnect(); + } + + function quoteString($string) + { + return $this->MDB_object->quoteString($string); + } + + function quote($string) + { + return $this->MDB_object->quote($string); + } + + function provides($feature) + { + return $this->MDB_object->provides($feature); + } + + function errorCode($nativecode) + { + return $this->MDB_object->errorCode($nativecode); + } + + function errorMessage($dbcode) + { + return $this->MDB_object->errorMessage($dbcode); + } + + function &raiseError($code = DB_ERROR, $mode = null, $options = null, + $userinfo = null, $nativecode = null) + { + return $this->MDB_object->raiseError($code = DB_ERROR, $mode, $options, $userinfo, $nativecode); + } + + function setFetchMode($fetchmode, $object_class = null) + { + return $this->MDB_object->setFetchMode($fetchmode, $object_class); + } + + function setOption($option, $value) + { + return $this->MDB_object->setOption($option, $value); + } + + function getOption($option) + { + return $this->MDB_object->getOption($option); + } + + function prepare($query) + { + return $this->MDB_object->prepare($query); + } + + function execute($stmt, $data = false) + { + $result = $this->MDB_object->execute($stmt, $data); + if (DB::isError($result) || $result === DB_OK) { + return $result; + } else { + return new DB_result($this->MDB_object, $result); + } + } + + function executeMultiple( $stmt, &$data ) + { + return $this->MDB_object->executeMultiple( $stmt, &$data ); + } + + function &query($query, $params = array()) { + $result = $this->MDB_object->query($query, $params); + if (DB::isError($result) || $result === DB_OK) { + return $result; + } else { + return new DB_result($this->MDB_object, $result); + } + } + + function limitQuery($query, $from, $count) + { + $result = $this->MDB_object->limitQuery($query, $from, $count); + if (DB::isError($result) || $result === DB_OK) { + return $result; + } else { + return new DB_result($this->MDB_object, $result); + } + } + + function &getOne($query, $params = array()) + { + return $this->MDB_object->getOne($query, $params); + } + + function &getRow($query, + $params = null, + $fetchmode = DB_FETCHMODE_DEFAULT) + { + return $this->MDB_object->getRow($query, $params, $fetchmode); + } + + + function &getCol($query, $col = 0, $params = array()) + { + return $this->MDB_object->getCol($query, $col, $params); + } + + + function &getAssoc($query, $force_array = false, $params = array(), + $fetchmode = DB_FETCHMODE_ORDERED, $group = false) + { + return $this->MDB_object->getAssoc($query, $force_array, $params, $fetchmode, $group); + } + + function &getAll($query, + $params = null, + $fetchmode = DB_FETCHMODE_DEFAULT) + { + return $this->MDB_object->getAll($query, $params, $fetchmode); + } + + function autoCommit($onoff=false) + { + return $this->MDB_object->autoCommit($onoff); + } + + function commit() + { + return $this->MDB_object->commit(); + } + + function rollback() + { + return $this->MDB_object->rollback(); } - function quoteString($string) - { - return $this->MDB_object->quoteString($string); - } - - function quote($string) - { - return $this->MDB_object->quote($string); - } - - function provides($feature) - { - return $this->MDB_object->provides($feature); - } - - function errorCode($nativecode) - { - return $this->MDB_object->errorCode($nativecode); - } - - function errorMessage($dbcode) - { - return $this->MDB_object->errorMessage($dbcode); - } - - function &raiseError($code = DB_ERROR, $mode = null, $options = null, - $userinfo = null, $nativecode = null) - { - return $this->MDB_object->raiseError($code = DB_ERROR, $mode, $options, $userinfo, $nativecode); - } - - function setFetchMode($fetchmode, $object_class = null) - { - return $this->MDB_object->setFetchMode($fetchmode, $object_class); - } - - function setOption($option, $value) - { - return $this->MDB_object->setOption($option, $value); - } - - function getOption($option) - { - return $this->MDB_object->getOption($option); - } - - function prepare($query) - { - return $this->MDB_object->prepare($query); - } - - function execute($stmt, $data = false) - { - $result = $this->MDB_object->execute($stmt, $data); - if (DB::isError($result) || $result === DB_OK) { - return $result; - } else { - return new DB_result($this->MDB_object, $result); - } - } - - function executeMultiple( $stmt, &$data ) - { - return $this->MDB_object->executeMultiple( $stmt, &$data ); - } - - function &query($query, $params = array()) { - $result = $this->MDB_object->query($query, $params); - if (DB::isError($result) || $result === DB_OK) { - return $result; - } else { - return new DB_result($this->MDB_object, $result); - } - } - - function limitQuery($query, $from, $count) - { - $result = $this->MDB_object->limitQuery($query, $from, $count); - if (DB::isError($result) || $result === DB_OK) { - return $result; - } else { - return new DB_result($this->MDB_object, $result); - } - } - - function &getOne($query, $params = array()) - { - return $this->MDB_object->getOne($query, $params); - } - - function &getRow($query, - $params = null, - $fetchmode = DB_FETCHMODE_DEFAULT) - { - return $this->MDB_object->getRow($query, $params, $fetchmode); - } - - - function &getCol($query, $col = 0, $params = array()) - { - return $this->MDB_object->getCol($query, $col, $params); - } - - - function &getAssoc($query, $force_array = false, $params = array(), - $fetchmode = DB_FETCHMODE_ORDERED, $group = false) - { - return $this->MDB_object->getAssoc($query, $force_array, $params, $fetchmode, $group); - } - - function &getAll($query, - $params = null, - $fetchmode = DB_FETCHMODE_DEFAULT) - { - return $this->MDB_object->getAll($query, $params, $fetchmode); - } - - function autoCommit($onoff=false) - { - return $this->MDB_object->autoCommit($onoff); - } - - function commit() - { - return $this->MDB_object->commit(); - } - - function rollback() - { - return $this->MDB_object->rollback(); - } - - function numRows($result) - { - return $this->MDB_object->numRows($result); - } - - function affectedRows() - { - return $this->MDB_object->affectedRows(); - } - - function errorNative() - { - return $this->MDB_object->errorNative(); - } - - function nextId($seq_name, $ondemand = true) - { - $return = $this->MDB_object->nextId($seq_name); - if($ondemand && $return == 0) - { - $this->MDB_object->createSequence($seq_name, 1); - $return = $this->MDB_object->nextId($seq_name); - } - return $return; - } - - function createSequence($seq_name) - { - return $this->MDB_object->createSequence($seq_name, 1); - } - - function dropSequence($seq_name) - { - return $this->MDB_object->dropSequence($seq_name); - } - - function tableInfo($result, $mode = null) - { - return $this->MDB_object->tableInfo($result, $mode); - } - - function getTables() - { - return $this->MDB_object->getTables(); - } - - function getListOf($type) - { - return $this->MDB_object->getListOf($type); - } + function numRows($result) + { + return $this->MDB_object->numRows($result); + } + + function affectedRows() + { + return $this->MDB_object->affectedRows(); + } + + function errorNative() + { + return $this->MDB_object->errorNative(); + } + + function nextId($seq_name, $ondemand = true) + { + $return = $this->MDB_object->nextId($seq_name); + if($ondemand && $return == 0) + { + $this->MDB_object->createSequence($seq_name, 1); + $return = $this->MDB_object->nextId($seq_name); + } + return $return; + } + + function createSequence($seq_name) + { + return $this->MDB_object->createSequence($seq_name, 1); + } + + function dropSequence($seq_name) + { + return $this->MDB_object->dropSequence($seq_name); + } + + function tableInfo($result, $mode = null) + { + return $this->MDB_object->tableInfo($result, $mode); + } + + function getTables() + { + return $this->MDB_object->getTables(); + } + + function getListOf($type) + { + return $this->MDB_object->getListOf($type); + } } ?>
« previous php.pear.cvs (#3868) next »