cvs: pear /LiveUser_Admin/Storage MDB2.php

From: Date: Sat, 12 Nov 2005 15:05:22 +0000
Subject: cvs: pear /LiveUser_Admin/Storage MDB2.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-36239@lists.php.net to get a copy of this message
lsmith Sat Nov 12 10:05:22 2005 EDT Modified files: /pear/LiveUser_Admin/Storage MDB2.php Log: - phpdoc fixes - renamed query() to exec() to match the MDB2 beta7 API - use exec() instead of query()

http://cvs.php.net/diff.php/pear/LiveUser_Admin/Storage/MDB2.php?r1=1.19&r2=1.20&ty=u Index: pear/LiveUser_Admin/Storage/MDB2.php diff -u pear/LiveUser_Admin/Storage/MDB2.php:1.19 pear/LiveUser_Admin/Storage/MDB2.php:1.20 --- pear/LiveUser_Admin/Storage/MDB2.php:1.19 Thu Sep 29 15:54:37 2005 +++ pear/LiveUser_Admin/Storage/MDB2.php Sat Nov 12 10:05:18 2005 @@ -57,7 +57,7 @@ * @author Bjoern Kraus <krausbn@php.net> * @copyright 2002-2005 Markus Wolff * @license http://www.gnu.org/licenses/lgpl.txt - * @version CVS: $Id: MDB2.php,v 1.19 2005/09/29 19:54:37 lsmith Exp $ + * @version CVS: $Id: MDB2.php,v 1.20 2005/11/12 15:05:18 lsmith Exp $ * @link http://pear.php.net/LiveUser_Admin */ @@ -73,12 +73,12 @@ * existing connection. Alternatively, a DSN can be passed to open a new one. * * Requirements: - * - File "Liveuser.php" (contains the parent class "LiveUser") + * - File "Liveuser/Admin.php" (contains the parent class "LiveUser_Admin") * - Array of connection options or a PEAR::MDB2 connection object must be - * passed to the constructor. + * passed to the init() method * Example: array('dsn' => 'mysql://user:pass@host/db_name') * OR - * &$conn (PEAR::MDB2 connection object) + * array('connection' => &$conn) ($conn is a PEAR::MDB2 connection object) * * @category authentication * @package LiveUser_Admin @@ -91,6 +91,12 @@ */ class LiveUser_Admin_Storage_MDB2 extends LiveUser_Admin_Storage_SQL { + /** + * determines of the use of sequences should be forced + * + * @var boolean + * @access private + */ var $force_seq = true; /** @@ -161,11 +167,10 @@ * * @param array $array data array * @param string $type determines type of the field - * * @return string comma seperated values * * @access public - * @uses MDB2::implodeArray + * @uses MDB2_Driver_Datatype_Common::implodeArray */ function implodeArray($array, $type) { @@ -178,7 +183,8 @@ * * @param string $limit number of rows to select * @param string $offset first row to select - * @return + * + * @return boolean * * @access public * @uses MDB2::setLimit @@ -186,22 +192,30 @@ function setLimit($limit, $offset) { if ($limit || $offset) { - return $this->dbc->setLimit($limit, $offset); + $result = $this->dbc->setLimit($limit, $offset); + if (PEAR::isError($result)) { + $this->_stack->push( + LIVEUSER_ADMIN_ERROR_QUERY_BUILDER, 'exception', + array('reason' => $result->getMessage() . '-' . $result->getUserInfo()) + ); + return false; + } } + return true; } /** - * Execute query + * Execute DML query * - * @param string $query query - * @return boolean | integer + * @param string $query DML query + * @return boolean | integer of the affected rows * * @access public - * @uses MDB::query + * @uses MDB2::exec */ - function query($query) + function exec($query) { - $result = $this->dbc->query($query); + $result = $this->dbc->exec($query); if (PEAR::isError($result)) { $this->_stack->push( LIVEUSER_ADMIN_ERROR_QUERY_BUILDER, 'exception', @@ -214,15 +228,13 @@ /** * Execute the specified query, fetch the value from the first column of - * the first row of the result set and then frees - * the result set. + * the first row of the result set and then frees the result set. * * @param string $query the SELECT query statement to be executed. - * @param string $type argument that specifies the expected - * datatype of the result set field, so that an eventual conversion - * may be performed. The default datatype is text, meaning that no - * conversion is performed - * @return boolean | array + * @param string $type argument that specifies the expected datatype of the + * result set field, so that an eventual conversion may be performed. + * The default datatype is text, meaning no conversion is performed. + * @return boolean | scalar * * @access public * @uses MDB2::queryOne @@ -246,10 +258,9 @@ * the result set. * * @param string $query the SELECT query statement to be executed. - * @param array $type array argument that specifies a list of - * expected datatypes of the result set columns, so that the eventual - * conversions may be performed. The default list of datatypes is - * empty, meaning that no conversion is performed. + * @param array $type argument that specifies a list of expected datatypes + * of theresult set columns, so that the conversions may be performed. + * The default datatype is text, meaning no conversion is performed. * @return boolean | array * * @access public @@ -273,10 +284,9 @@ * each row of the result set into an array and then frees the result set. * * @param string $query the SELECT query statement to be executed. - * @param string $type argument that specifies the expected - * datatype of the result set field, so that an eventual conversion - * may be performed. The default datatype is text, meaning that no - * conversion is performed + * @param string $type argument that specifies the expected datatype of the + * result set field, so that an eventual conversion may be performed. + * The default datatype is text, meaning no conversion is performed. * @return boolean | array * * @access public @@ -300,11 +310,10 @@ * a two dimensional array and then frees the result set. * * @param string $query the SELECT query statement to be executed. - * @param array $types array argument that specifies a list of - * expected datatypes of the result set columns, so that the eventual - * conversions may be performed. The default list of datatypes is - * empty, meaning that no conversion is performed. - * @param boolean $rekey if set to true, the $all will have the first + * @param array $type argument that specifies a list of expected datatypes + * of theresult set columns, so that the conversions may be performed. + * The default datatype is text, meaning no conversion is performed. + * @param boolean $rekey if set to true, returned array will have the first * column as its first dimension * @param boolean $group if set to true and $rekey is set to true, then * all values with the same first column will be wrapped in an array @@ -332,7 +341,7 @@ * @param string $seqname name of the sequence * @param boolean $ondemand when true the seqence is * automatic created, if it not exists - * @return boolean | integer + * @return boolean | integer false on failure or next id for the table * * @access public * @uses MDB2::nextId @@ -360,14 +369,15 @@ * @return boolean | integer * * @access public - * @uses MDB2::nextId MDB2::getBeforeId + * @uses MDB2::nextId MDB2_Extended::getBeforeId */ function getBeforeId($table, $ondemand = true) { if ($this->force_seq) { $result = $this->dbc->nextId($table, $ondemand); } else { - $result = $this->dbc->getBeforeId($table); + $this->loadModule('Extended'); + $result = $this->dbc->extended->getBeforeId($table); } if (PEAR::isError($result)) { @@ -388,7 +398,7 @@ * @return boolean | integer returns the id that the users passed via params * * @access public - * @uses MDB2::getAfterId + * @uses MDB2_Extended::getAfterId */ function getAfterId($id, $table) { @@ -396,7 +406,8 @@ return $id; } - $result = $this->dbc->getAfterId($id, $table); + $this->loadModule('Extended'); + $result = $this->dbc->extended->getAfterId($id, $table); if (PEAR::isError($result)) { $this->_stack->push( LIVEUSER_ADMIN_ERROR_QUERY_BUILDER, 'exception',
« previous php.pear.cvs (#36239) next »