cvs: pear /DB_Table/DB Table.php /DB_Table/DB/Table Manager.php

From: Date: Mon, 02 Jan 2006 16:45:07 +0000
Subject: cvs: pear /DB_Table/DB Table.php /DB_Table/DB/Table Manager.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-37256@lists.php.net to get a copy of this message
wiesemann Mon Jan 2 16:45:07 2006 UTC Modified files: /pear/DB_Table/DB Table.php /pear/DB_Table/DB/Table Manager.php Log: more changes regarding MDB2 support (mostly comments / phpdoc)

http://cvs.php.net/viewcvs.cgi/pear/DB_Table/DB/Table.php?r1=1.49&r2=1.50&diff_format=u Index: pear/DB_Table/DB/Table.php diff -u pear/DB_Table/DB/Table.php:1.49 pear/DB_Table/DB/Table.php:1.50 --- pear/DB_Table/DB/Table.php:1.49 Mon Jan 2 16:15:11 2006 +++ pear/DB_Table/DB/Table.php Mon Jan 2 16:45:07 2006 @@ -19,7 +19,7 @@ * * @license http://www.gnu.org/copyleft/lesser.html LGPL * -* @version $Id: Table.php,v 1.49 2006/01/02 16:15:11 wiesemann Exp $ +* @version $Id: Table.php,v 1.50 2006/01/02 16:45:07 wiesemann Exp $ * */ @@ -458,7 +458,7 @@ * * When calling select() and selectResult(), use this fetch mode (usually * a DB_FETCHMODE_* constant). If null, uses whatever is set in the $db - * PEAR DB object. + * PEAR DB/MDB2 object. * * @access public * @@ -473,7 +473,7 @@ * * When fetchmode is DB_FETCHMODE_OBJECT, use this class for each * returned row. If null, uses whatever is set in the $db - * PEAR DB object. + * PEAR DB/MDB2 object. * * @access public * @@ -525,8 +525,8 @@ */ var $_error_messages = array( - DB_TABLE_ERR_NOT_DB_OBJECT => 'First parameter must be a DB object', - DB_TABLE_ERR_PHPTYPE => 'DB phptype not supported', + DB_TABLE_ERR_NOT_DB_OBJECT => 'First parameter must be a DB/MDB2 object', + DB_TABLE_ERR_PHPTYPE => 'DB/MDB2 phptype not supported', DB_TABLE_ERR_SQL_UNDEF => 'Select key not in map', DB_TABLE_ERR_INS_COL_NOMAP => 'Insert column not in map', DB_TABLE_ERR_INS_COL_REQUIRED => 'Insert data must be set and non-null for column', @@ -617,7 +617,7 @@ * * @access public * - * @param object &$db A PEAR DB object. + * @param object &$db A PEAR DB/MDB2 object. * * @param string $table The table name to connect to in the database. * @@ -641,7 +641,7 @@ $this->setErrorMessage($GLOBALS['_DB_TABLE']['error']); } - // is the first argument a DB object? + // is the first argument a DB/MDB2 object? $this->backend = null; if (! is_subclass_of($db, 'db_common')) { $this->backend = 'db'; @@ -842,7 +842,7 @@ /** * - * Selects rows from the table using one of the 'DB::get*()' methods. + * Selects rows from the table using one of the DB/MDB2 get*() methods. * * @access public * @@ -867,14 +867,24 @@ * 'getOne'), a single value (if 'getOne'), or a PEAR_Error object. * * @see DB::getAll() + * + * @see MDB2::getAll() * * @see DB::getAssoc() + * + * @see MDB2::getAssoc() * * @see DB::getCol() + * + * @see MDB2::getCol() * * @see DB::getOne() * + * @see MDB2::getOne() + * * @see DB::getRow() + * + * @see MDB2::getRow() * * @see DB_Table::_swapModes() * @@ -897,7 +907,7 @@ $method = 'getAll'; } - // DB_Table assumes you are using a shared PEAR DB object. Other + // DB_Table assumes you are using a shared PEAR DB/MDB2 object. Other // scripts using the same object probably expect its fetchmode // not to change, unless they change it themselves. Thus, to // provide friendly mode-swapping, we will restore these modes @@ -925,32 +935,24 @@ } // get the result - switch ($method) { - - case 'getCol': - if ($this->backend == 'mdb2') { - $result = $this->db->extended->$method($sql, null, $params); - } else { - $result = $this->db->$method($sql, 0, $params); - } - break; + if ($this->backend == 'mdb2') { + $result = $this->db->extended->$method($sql, null, $params); + } else { + switch ($method) { - case 'getAssoc': - if ($this->backend == 'mdb2') { - $result = $this->db->extended->$method($sql, null, $params); - } else { - $result = $this->db->$method($sql, false, $params); - } - break; + case 'getCol': + $result = $this->db->$method($sql, 0, $params); + break; + + case 'getAssoc': + $result = $this->db->$method($sql, false, $params); + break; + + default: + $result = $this->db->$method($sql, $params); + break; - default: - if ($this->backend == 'mdb2') { - $result = $this->db->extended->$method($sql, null, $params); - } else { - $result = $this->db->$method($sql, $params); } - break; - } // swap modes back @@ -963,7 +965,7 @@ /** * - * Selects rows from the table as a DB_Result object. + * Selects rows from the table as a DB_Result/MDB2_Result_* object. * * @access public * @@ -984,8 +986,8 @@ * @param array $params Parameters to use in placeholder substitutions (if * any). * - * @return mixed A PEAR_Error on failure, or a DB_Result object on - * success. + * @return mixed A PEAR_Error on failure, or a DB_Result/MDB2_Result_* + * object on success. * * @see DB_Table::_swapModes() * @@ -1000,7 +1002,7 @@ return $sql; } - // DB_Table assumes you are using a shared PEAR DB object. Other + // DB_Table assumes you are using a shared PEAR DB/MDB2 object. Other // scripts using the same object probably expect its fetchmode // not to change, unless they change it themselves. Thus, to // provide friendly mode-swapping, we will restore these modes @@ -1129,22 +1131,22 @@ /** * - * Changes the $this->db PEAR DB object fetchmode and + * Changes the $this->db PEAR DB/MDB2 object fetchmode and * fetchmode_object_class. * - * Becase DB_Table objects tend to use the same PEAR DB object, it + * Because DB_Table objects tend to use the same PEAR DB/MDB2 object, it * may sometimes be useful to have one object return results in one * mode, and have another object return results in a different mode. - * This method allows us to switch DB fetch modes on the fly. + * This method allows us to switch DB/MDB2 fetch modes on the fly. * * @access private * * @param string $new_mode A DB_FETCHMODE_* constant. If null, - * defaults to whatever the DB object is currently using. + * defaults to whatever the DB/MDB2 object is currently using. * * @param string $new_class The object class to use for results when * the $db object is in DB_FETCHMODE_OBJECT fetch mode. If null, - * defaults to whatever the the DB object is currently using. + * defaults to whatever the the DB/MDB2 object is currently using. * * @return void * @@ -1314,6 +1316,8 @@ * * @see DB::autoExecute() * + * @see MDB2::autoExecute() + * */ function insert($data) @@ -1444,6 +1448,8 @@ * * @see DB::autoExecute() * + * @see MDB2::autoExecute() + * */ function update($data, $where) @@ -1566,6 +1572,8 @@ * * @see DB::query() * + * @see MDB2::exec() + * */ function delete($where) @@ -1590,6 +1598,8 @@ * @return integer The next value in the sequence. * * @see DB::nextID() + * + * @see MDB2::nextID() * */ @@ -1601,7 +1611,7 @@ $seq_name = "{$this->table}_{$seq_name}"; } - // the maximum length is 30, but PEAR DB will add "_seq" to the + // the maximum length is 30, but PEAR DB/MDB2 will add "_seq" to the // name, so the max length here is less 4 chars. we have to // check here because the sequence will be created automatically // by PEAR DB, which will not check for length on its own. http://cvs.php.net/viewcvs.cgi/pear/DB_Table/DB/Table/Manager.php?r1=1.13&r2=1.14&diff_format=u Index: pear/DB_Table/DB/Table/Manager.php diff -u pear/DB_Table/DB/Table/Manager.php:1.13 pear/DB_Table/DB/Table/Manager.php:1.14 --- pear/DB_Table/DB/Table/Manager.php:1.13 Sun Jan 1 10:44:25 2006 +++ pear/DB_Table/DB/Table/Manager.php Mon Jan 2 16:45:07 2006 @@ -16,7 +16,7 @@ * * @license http://www.gnu.org/copyleft/lesser.html LGPL * -* @version $Id: Manager.php,v 1.13 2006/01/01 10:44:25 wiesemann Exp $ +* @version $Id: Manager.php,v 1.14 2006/01/02 16:45:07 wiesemann Exp $ * */ @@ -50,7 +50,7 @@ * * @access public * - * @param object &$db A PEAR DB object. + * @param object &$db A PEAR DB/MDB2 object. * * @param string $table The table name to connect to in the database. * @@ -74,10 +74,10 @@ // is the table name too long? if (strlen($table) > 30) { - return DB_Table::throwError( - DB_TABLE_ERR_TABLE_STRLEN, - " ('$table')" - ); + return DB_Table::throwError( + DB_TABLE_ERR_TABLE_STRLEN, + " ('$table')" + ); } @@ -110,10 +110,10 @@ // column must be no longer than 30 chars if (strlen($colname) > 30) { - return DB_Table::throwError( - DB_TABLE_ERR_DECLARE_STRLEN, - "('$colname')" - ); + return DB_Table::throwError( + DB_TABLE_ERR_DECLARE_STRLEN, + "('$colname')" + ); } @@ -216,10 +216,10 @@ // now check the length; must be under 30 chars to // soothe Oracle. if (strlen($newIdxName) > 30) { - return DB_Table::throwError( - DB_TABLE_ERR_IDX_STRLEN, - "'$idxname' ('$newIdxName')" - ); + return DB_Table::throwError( + DB_TABLE_ERR_IDX_STRLEN, + "'$idxname' ('$newIdxName')" + ); } // create index entry @@ -274,7 +274,7 @@ * * @access public * - * @param object &$db A PEAR DB object. + * @param object &$db A PEAR DB/MDB2 object. * * @param string $table The table name to connect to in the database. * @@ -289,6 +289,8 @@ function verify(&$db, $table, $column_set, $index_set) { + // TODO: add verify functionality for MDB2 + // check #1: does the table exist? $tableInfo = $db->tableInfo($table, DB_TABLEINFO_FULL); if (PEAR::isError($tableInfo)) { @@ -498,7 +500,7 @@ * * @access public * - * @param string $phptype The DB phptype key. + * @param string $phptype The DB/MDB2 phptype key. * * @param string $coltype The DB_Table column type. *
« previous php.pear.cvs (#37256) next »