/**
* Database independent query interface
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: DB.php,v 1.88 2007/08/12 05:27:25 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.13
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
*/
class DB
{
- // {{{ &factory()
+ // {{{ factory()
/**
* Create a new DB object for the specified database type but don't
*
* @see DB_common::setOption()
*/
- function &factory($type, $options = false)
+ public static function factory($type, $options = false)
{
if (!is_array($options)) {
$options = array('persistent' => $options);
}
// }}}
- // {{{ &connect()
+ // {{{ connect()
/**
* Create a new DB object including a connection to the specified database
* 'portability' => DB_PORTABILITY_ALL,
* );
*
- * $db =& DB::connect($dsn, $options);
+ * $db = DB::connect($dsn, $options);
* if (PEAR::isError($db)) {
* die($db->getMessage());
* }
*
* @uses DB::parseDSN(), DB_common::setOption(), PEAR::isError()
*/
- function &connect($dsn, $options = array())
+ public static function connect($dsn, $options = array())
{
$dsninfo = DB::parseDSN($dsn);
$type = $dsninfo['phptype'];
if (!class_exists($classname)) {
$tmp = PEAR::raiseError(null, DB_ERROR_NOT_FOUND, null, null,
"Unable to include the DB/{$type}.php"
- . " file for '$dsn'",
+ . " file for '"
+ . DB::getDSNString($dsn, true) . "'",
'DB_Error', true);
return $tmp;
}
*/
function apiVersion()
{
- return '1.7.13';
+ return '1.8.2';
}
// }}}
*
* @return bool whether $value is DB_Error object
*/
- function isError($value)
+ public static function isError($value)
{
- return is_a($value, 'DB_Error');
+ return is_object($value) && is_a($value, 'DB_Error');
}
// }}}
*
* @return bool whether $value is a DB_<driver> object
*/
- function isConnection($value)
+ public static function isConnection($value)
{
return (is_object($value) &&
is_subclass_of($value, 'db_common') &&
*
* @return boolean whether $query is a data manipulation query
*/
- function isManip($query)
+ public static function isManip($query)
{
$manips = 'INSERT|UPDATE|DELETE|REPLACE|'
. 'CREATE|DROP|'
* @return string the error message or false if the error code was
* not recognized
*/
- function errorMessage($value)
+ public static function errorMessage($value)
{
static $errorMessages;
if (!isset($errorMessages)) {
* + username: User name for login
* + password: Password for login
*/
- function parseDSN($dsn)
+ public static function parseDSN($dsn)
{
$parsed = array(
'phptype' => false,
* @param boolean true to hide the password, false to include it
* @return string
*/
- function getDSNString($dsn, $hidePassword) {
+ public static function getDSNString($dsn, $hidePassword) {
/* Calling parseDSN will ensure that we have all the array elements
* defined, and means that we deal with strings and array in the same
* manner. */
* @author Stig Bakken <ssb@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.13
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
*/
class DB_Error extends PEAR_Error
* @author Stig Bakken <ssb@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.13
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
*/
class DB_result
* @author Stig Bakken <ssb@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.13
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
* @see DB_common::setFetchMode()
*/
/**
* Contains the DB_common base class
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: common.php,v 1.144 2007/11/26 22:54:03 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.14RC1
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
*/
class DB_common extends PEAR
function __wakeup()
{
if ($this->was_connected) {
- $this->connect($this->dsn, $this->options);
+ $this->connect($this->dsn, $this->options['persistent']);
}
}
*/
function quoteString($string)
{
- $string = $this->quote($string);
+ $string = $this->quoteSmart($string);
if ($string{0} == "'") {
return substr($string, 1, -1);
}
*/
function quote($string = null)
{
- return ($string === null) ? 'NULL'
- : "'" . str_replace("'", "''", $string) . "'";
+ return $this->quoteSmart($string);
}
// }}}
return $query;
}
$result = $this->query($query, $params);
- if (is_a($result, 'DB_result')) {
+ if (is_object($result) && is_a($result, 'DB_result')) {
$result->setOption('limit_from', $from);
$result->setOption('limit_count', $count);
}
* The PEAR DB driver for PHP's dbase extension
* for interacting with dBase databases
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: dbase.php,v 1.45 2007/09/21 13:40:41 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.14RC1
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
*/
class DB_dbase extends DB_common
* The PEAR DB driver for PHP's fbsql extension
* for interacting with FrontBase databases
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: fbsql.php,v 1.88 2007/07/06 05:19:21 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.14RC1
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
* @since Class functional since Release 1.7.0
*/
* While this class works with PHP 4, PHP's InterBase extension is
* unstable in PHP 4. Use PHP 5.
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: ibase.php,v 1.116 2007/09/21 13:40:41 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.14RC1
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
* @since Class became stable in Release 1.7.0
*/
$error_regexps = array(
'/generator .* is not defined/'
=> DB_ERROR_SYNTAX, // for compat. w ibase_errcode()
+ '/violation of [\w ]+ constraint/i'
+ => DB_ERROR_CONSTRAINT,
'/table.*(not exist|not found|unknown)/i'
=> DB_ERROR_NOSUCHTABLE,
'/table .* already exists/i'
=> DB_ERROR_NOT_FOUND,
'/validation error for column .* value "\*\*\* null/i'
=> DB_ERROR_CONSTRAINT_NOT_NULL,
- '/violation of [\w ]+ constraint/i'
- => DB_ERROR_CONSTRAINT,
'/conversion error from string/i'
=> DB_ERROR_INVALID_NUMBER,
'/no permission for/i'
* The PEAR DB driver for PHP's ifx extension
* for interacting with Informix databases
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: ifx.php,v 1.75 2007/07/06 05:19:21 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.14RC1
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
*/
class DB_ifx extends DB_common
*/
function errorCode($nativecode)
{
- if (ereg('SQLCODE=(.*)]', $nativecode, $match)) {
+ if (preg_match('/SQLCODE=(.*)]/', $nativecode, $match)) {
$code = $match[1];
if (isset($this->errorcode_map[$code])) {
return $this->errorcode_map[$code];
* 4.3.11 and 5.0.4. Make sure your version of PHP meets or exceeds
* those versions.
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: msql.php,v 1.64 2007/09/21 13:40:41 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.14RC1
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
* @since Class not functional until Release 1.7.0
*/
* The PEAR DB driver for PHP's mssql extension
* for interacting with Microsoft SQL Server databases
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: mssql.php,v 1.92 2007/09/21 13:40:41 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.14RC1
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
*/
class DB_mssql extends DB_common
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name));
}
+ // }}}
+ // {{{ escapeSimple()
+
+ /**
+ * Escapes a string in a manner suitable for SQL Server.
+ *
+ * @param string $str the string to be escaped
+ * @return string the escaped string
+ *
+ * @see DB_common::quoteSmart()
+ * @since Method available since Release 1.6.0
+ */
+ function escapeSimple($str)
+ {
+ return str_replace(
+ array("'", "\\\r\n", "\\\n"),
+ array("''", "\\\\\r\n\r\n", "\\\\\n\n"),
+ $str
+ );
+ }
+
// }}}
// {{{ quoteIdentifier()
* The PEAR DB driver for PHP's mysql extension
* for interacting with MySQL databases
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: mysql.php,v 1.126 2007/09/21 13:32:52 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.14RC1
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
*/
class DB_mysql extends DB_common
return '`' . str_replace('`', '``', $str) . '`';
}
- // }}}
- // {{{ quote()
-
- /**
- * @deprecated Deprecated in release 1.6.0
- */
- function quote($str)
- {
- return $this->quoteSmart($str);
- }
-
// }}}
// {{{ escapeSimple()
* The PEAR DB driver for PHP's mysqli extension
* for interacting with MySQL databases
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: mysqli.php,v 1.82 2007/09/21 13:40:41 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.14RC1
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
* @since Class functional since Release 1.6.3
*/
$got_string = false;
}
- if (!is_a($id, 'mysqli_result')) {
+ if (!is_object($id) || !is_a($id, 'mysqli_result')) {
return $this->mysqliRaiseError(DB_ERROR_NEED_MORE_DATA);
}
* The PEAR DB driver for PHP's oci8 extension
* for interacting with Oracle databases
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: oci8.php,v 1.116 2007/11/28 02:22:39 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.14RC1
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
*/
class DB_oci8 extends DB_common
if (isset($this->prepare_types[(int)$stmt])) {
unset($this->prepare_types[(int)$stmt]);
unset($this->manip_query[(int)$stmt]);
+ unset($this->_prepared_queries[(int)$stmt]);
} else {
return false;
}
$tmp = $this->oci8RaiseError($stmt);
return $tmp;
}
- $this->last_query = preg_replace("/:bind$i/",$this->quoteSmart($data[$key]),$this->last_query,1);
+ $this->last_query = preg_replace("/:bind$i(?!\d)/",
+ $this->quoteSmart($data[$key]), $this->last_query, 1);
$i++;
}
if ($this->autocommit) {
* The PEAR DB driver for PHP's odbc extension
* for interacting with databases via ODBC connections
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: odbc.php,v 1.81 2007/07/06 05:19:21 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.14RC1
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
*/
class DB_odbc extends DB_common
}
}
- // }}}
- // {{{ quote()
-
- /**
- * @deprecated Deprecated in release 1.6.0
- * @internal
- */
- function quote($str)
- {
- return $this->quoteSmart($str);
- }
-
// }}}
// {{{ nextId()
* The PEAR DB driver for PHP's pgsql extension
* for interacting with PostgreSQL databases
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: pgsql.php,v 1.139 2007/11/28 02:19:44 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.14RC1
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
*/
class DB_pgsql extends DB_common
* CREATE, DECLARE, DELETE, DROP TABLE, EXPLAIN, FETCH,
* GRANT, INSERT, LISTEN, LOAD, LOCK, MOVE, NOTIFY, RESET,
* REVOKE, ROLLBACK, SELECT, SELECT INTO, SET, SHOW,
- * UNLISTEN, UPDATE, VACUUM
+ * UNLISTEN, UPDATE, VACUUM, WITH
*/
if ($ismanip) {
$this->affected = @pg_affected_rows($result);
return DB_OK;
- } elseif (preg_match('/^\s*\(*\s*(SELECT|EXPLAIN|FETCH|SHOW)\s/si',
+ } elseif (preg_match('/^\s*\(*\s*(SELECT|EXPLAIN|FETCH|SHOW|WITH)\s/si',
$query))
{
$this->row[(int)$result] = 0; // reset the row counter.
return false;
}
- // }}}
- // {{{ quote()
-
- /**
- * @deprecated Deprecated in release 1.6.0
- * @internal
- */
- function quote($str)
- {
- return $this->quoteSmart($str);
- }
-
// }}}
// {{{ quoteBoolean()
* The PEAR DB driver for PHP's sqlite extension
* for interacting with SQLite databases
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0 3.0
- * @version CVS: $Id: sqlite.php,v 1.118 2007/11/26 22:57:18 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0 3.0
- * @version Release: 1.7.14RC1
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
*/
class DB_sqlite extends DB_common
$flags = '';
if ($id[$i]['pk']) {
$flags .= 'primary_key ';
+ if (strtoupper($type) == 'INTEGER') {
+ $flags .= 'auto_increment ';
+ }
}
if ($id[$i]['notnull']) {
$flags .= 'not_null ';
/**
* Provides an object interface to a table row
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Stig Bakken <stig@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: storage.php,v 1.24 2007/08/12 05:27:25 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Stig Bakken <stig@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.14RC1
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
*/
class DB_storage extends PEAR
* The PEAR DB driver for PHP's sybase extension
* for interacting with Sybase databases
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: sybase.php,v 1.87 2007/09/21 13:40:42 aharvey Exp $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/DB
*/
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.7.14RC1
+ * @version Release: 1.8.2
* @link http://pear.php.net/package/DB
*/
class DB_sybase extends DB_common