|
|
@ -43,7 +43,7 @@
|
|
|
|
// | Author: Lukas Smith <smith@pooteeweet.org> |
|
|
|
|
// | Author: Lukas Smith <smith@pooteeweet.org> |
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $Id: MDB2.php 292663 2009-12-26 18:21:46Z quipo $
|
|
|
|
// $Id: MDB2.php 295587 2010-02-28 17:16:38Z quipo $
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -267,7 +267,7 @@ $GLOBALS['_MDB2_dsninfo_default'] = array(
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class MDB2
|
|
|
|
class MDB2
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// {{{ function setOptions(&$db, $options)
|
|
|
|
// {{{ function setOptions($db, $options)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* set option array in an exiting database object
|
|
|
|
* set option array in an exiting database object
|
|
|
@ -279,7 +279,7 @@ class MDB2
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function setOptions(&$db, $options)
|
|
|
|
static function setOptions($db, $options)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (is_array($options)) {
|
|
|
|
if (is_array($options)) {
|
|
|
|
foreach ($options as $option => $value) {
|
|
|
|
foreach ($options as $option => $value) {
|
|
|
@ -304,12 +304,9 @@ class MDB2
|
|
|
|
* @static
|
|
|
|
* @static
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function classExists($classname)
|
|
|
|
static function classExists($classname)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (version_compare(phpversion(), "5.0", ">=")) {
|
|
|
|
return class_exists($classname, false);
|
|
|
|
return class_exists($classname, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return class_exists($classname);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
@ -325,7 +322,7 @@ class MDB2
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function loadClass($class_name, $debug)
|
|
|
|
static function loadClass($class_name, $debug)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!MDB2::classExists($class_name)) {
|
|
|
|
if (!MDB2::classExists($class_name)) {
|
|
|
|
$file_name = str_replace('_', DIRECTORY_SEPARATOR, $class_name).'.php';
|
|
|
|
$file_name = str_replace('_', DIRECTORY_SEPARATOR, $class_name).'.php';
|
|
|
@ -340,12 +337,12 @@ class MDB2
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$msg = "unable to load class '$class_name' from file '$file_name'";
|
|
|
|
$msg = "unable to load class '$class_name' from file '$file_name'";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$err =& MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, $msg);
|
|
|
|
$err = MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, $msg);
|
|
|
|
return $err;
|
|
|
|
return $err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!MDB2::classExists($class_name)) {
|
|
|
|
if (!MDB2::classExists($class_name)) {
|
|
|
|
$msg = "unable to load class '$class_name' from file '$file_name'";
|
|
|
|
$msg = "unable to load class '$class_name' from file '$file_name'";
|
|
|
|
$err =& MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, $msg);
|
|
|
|
$err = MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, $msg);
|
|
|
|
return $err;
|
|
|
|
return $err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -353,21 +350,11 @@ class MDB2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
|
// {{{ function &factory($dsn, $options = false)
|
|
|
|
// {{{ function factory($dsn, $options = false)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Create a new MDB2 object for the specified database type
|
|
|
|
* Create a new MDB2 object for the specified database type
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IMPORTANT: In order for MDB2 to work properly it is necessary that
|
|
|
|
|
|
|
|
* you make sure that you work with a reference of the original
|
|
|
|
|
|
|
|
* object instead of a copy (this is a PHP4 quirk).
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* For example:
|
|
|
|
|
|
|
|
* $db =& MDB2::factory($dsn);
|
|
|
|
|
|
|
|
* ^^
|
|
|
|
|
|
|
|
* And not:
|
|
|
|
|
|
|
|
* $db = MDB2::factory($dsn);
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param mixed 'data source name', see the MDB2::parseDSN
|
|
|
|
* @param mixed 'data source name', see the MDB2::parseDSN
|
|
|
|
* method for a description of the dsn format.
|
|
|
|
* method for a description of the dsn format.
|
|
|
|
* Can also be specified as an array of the
|
|
|
|
* Can also be specified as an array of the
|
|
|
@ -379,11 +366,11 @@ class MDB2
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function &factory($dsn, $options = false)
|
|
|
|
static function factory($dsn, $options = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$dsninfo = MDB2::parseDSN($dsn);
|
|
|
|
$dsninfo = MDB2::parseDSN($dsn);
|
|
|
|
if (empty($dsninfo['phptype'])) {
|
|
|
|
if (empty($dsninfo['phptype'])) {
|
|
|
|
$err =& MDB2::raiseError(MDB2_ERROR_NOT_FOUND,
|
|
|
|
$err = MDB2::raiseError(MDB2_ERROR_NOT_FOUND,
|
|
|
|
null, null, 'no RDBMS driver specified');
|
|
|
|
null, null, 'no RDBMS driver specified');
|
|
|
|
return $err;
|
|
|
|
return $err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -406,23 +393,12 @@ class MDB2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
|
// {{{ function &connect($dsn, $options = false)
|
|
|
|
// {{{ function connect($dsn, $options = false)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Create a new MDB2_Driver_* connection object and connect to the specified
|
|
|
|
* Create a new MDB2_Driver_* connection object and connect to the specified
|
|
|
|
* database
|
|
|
|
* database
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IMPORTANT: In order for MDB2 to work properly it is necessary that
|
|
|
|
|
|
|
|
* you make sure that you work with a reference of the original
|
|
|
|
|
|
|
|
* object instead of a copy (this is a PHP4 quirk).
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* For example:
|
|
|
|
|
|
|
|
* $db =& MDB2::connect($dsn);
|
|
|
|
|
|
|
|
* ^^
|
|
|
|
|
|
|
|
* And not:
|
|
|
|
|
|
|
|
* $db = MDB2::connect($dsn);
|
|
|
|
|
|
|
|
* ^^
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param mixed $dsn 'data source name', see the MDB2::parseDSN
|
|
|
|
* @param mixed $dsn 'data source name', see the MDB2::parseDSN
|
|
|
|
* method for a description of the dsn format.
|
|
|
|
* method for a description of the dsn format.
|
|
|
|
* Can also be specified as an array of the
|
|
|
|
* Can also be specified as an array of the
|
|
|
@ -436,9 +412,9 @@ class MDB2
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
* @see MDB2::parseDSN
|
|
|
|
* @see MDB2::parseDSN
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function &connect($dsn, $options = false)
|
|
|
|
static function connect($dsn, $options = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$db =& MDB2::factory($dsn, $options);
|
|
|
|
$db = MDB2::factory($dsn, $options);
|
|
|
|
if (PEAR::isError($db)) {
|
|
|
|
if (PEAR::isError($db)) {
|
|
|
|
return $db;
|
|
|
|
return $db;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -455,24 +431,13 @@ class MDB2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
|
// {{{ function &singleton($dsn = null, $options = false)
|
|
|
|
// {{{ function singleton($dsn = null, $options = false)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns a MDB2 connection with the requested DSN.
|
|
|
|
* Returns a MDB2 connection with the requested DSN.
|
|
|
|
* A new MDB2 connection object is only created if no object with the
|
|
|
|
* A new MDB2 connection object is only created if no object with the
|
|
|
|
* requested DSN exists yet.
|
|
|
|
* requested DSN exists yet.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IMPORTANT: In order for MDB2 to work properly it is necessary that
|
|
|
|
|
|
|
|
* you make sure that you work with a reference of the original
|
|
|
|
|
|
|
|
* object instead of a copy (this is a PHP4 quirk).
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* For example:
|
|
|
|
|
|
|
|
* $db =& MDB2::singleton($dsn);
|
|
|
|
|
|
|
|
* ^^
|
|
|
|
|
|
|
|
* And not:
|
|
|
|
|
|
|
|
* $db = MDB2::singleton($dsn);
|
|
|
|
|
|
|
|
* ^^
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param mixed 'data source name', see the MDB2::parseDSN
|
|
|
|
* @param mixed 'data source name', see the MDB2::parseDSN
|
|
|
|
* method for a description of the dsn format.
|
|
|
|
* method for a description of the dsn format.
|
|
|
|
* Can also be specified as an array of the
|
|
|
|
* Can also be specified as an array of the
|
|
|
@ -486,7 +451,7 @@ class MDB2
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
* @see MDB2::parseDSN
|
|
|
|
* @see MDB2::parseDSN
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function &singleton($dsn = null, $options = false)
|
|
|
|
static function singleton($dsn = null, $options = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ($dsn) {
|
|
|
|
if ($dsn) {
|
|
|
|
$dsninfo = MDB2::parseDSN($dsn);
|
|
|
|
$dsninfo = MDB2::parseDSN($dsn);
|
|
|
@ -502,10 +467,9 @@ class MDB2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} elseif (is_array($GLOBALS['_MDB2_databases']) && reset($GLOBALS['_MDB2_databases'])) {
|
|
|
|
} elseif (is_array($GLOBALS['_MDB2_databases']) && reset($GLOBALS['_MDB2_databases'])) {
|
|
|
|
$db =& $GLOBALS['_MDB2_databases'][key($GLOBALS['_MDB2_databases'])];
|
|
|
|
return $GLOBALS['_MDB2_databases'][key($GLOBALS['_MDB2_databases'])];
|
|
|
|
return $db;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$db =& MDB2::factory($dsn, $options);
|
|
|
|
$db = MDB2::factory($dsn, $options);
|
|
|
|
return $db;
|
|
|
|
return $db;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -521,7 +485,7 @@ class MDB2
|
|
|
|
* @param array $arr2
|
|
|
|
* @param array $arr2
|
|
|
|
* @return boolean
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function areEquals($arr1, $arr2)
|
|
|
|
static function areEquals($arr1, $arr2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (count($arr1) != count($arr2)) {
|
|
|
|
if (count($arr1) != count($arr2)) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -540,13 +504,13 @@ class MDB2
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* load a file (like 'Date')
|
|
|
|
* load a file (like 'Date')
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param string name of the file in the MDB2 directory (without '.php')
|
|
|
|
* @param string $file name of the file in the MDB2 directory (without '.php')
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return string name of the file that was included
|
|
|
|
* @return string name of the file that was included
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function loadFile($file)
|
|
|
|
static function loadFile($file)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$file_name = 'MDB2'.DIRECTORY_SEPARATOR.$file.'.php';
|
|
|
|
$file_name = 'MDB2'.DIRECTORY_SEPARATOR.$file.'.php';
|
|
|
|
if (!MDB2::fileExists($file_name)) {
|
|
|
|
if (!MDB2::fileExists($file_name)) {
|
|
|
@ -630,17 +594,16 @@ class MDB2
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function isError($data, $code = null)
|
|
|
|
static function isError($data, $code = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (is_a($data, 'MDB2_Error')) {
|
|
|
|
if ($data instanceof MDB2_Error) {
|
|
|
|
if (null === $code) {
|
|
|
|
if (null === $code) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
} elseif (is_string($code)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_string($code)) {
|
|
|
|
return $data->getMessage() === $code;
|
|
|
|
return $data->getMessage() === $code;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$code = (array)$code;
|
|
|
|
|
|
|
|
return in_array($data->getCode(), $code);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return in_array($data->getCode(), (array)$code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -654,12 +617,11 @@ class MDB2
|
|
|
|
* @param mixed value to test
|
|
|
|
* @param mixed value to test
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return bool whether $value is a MDB2 connection
|
|
|
|
* @return bool whether $value is a MDB2 connection
|
|
|
|
*
|
|
|
|
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function isConnection($value)
|
|
|
|
function isConnection($value)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return is_a($value, 'MDB2_Driver_Common');
|
|
|
|
return ($value instanceof MDB2_Driver_Common);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
@ -668,15 +630,15 @@ class MDB2
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Tell whether a value is a MDB2 result
|
|
|
|
* Tell whether a value is a MDB2 result
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param mixed value to test
|
|
|
|
* @param mixed $value value to test
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return bool whether $value is a MDB2 result
|
|
|
|
* @return bool whether $value is a MDB2 result
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function isResult($value)
|
|
|
|
function isResult($value)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return is_a($value, 'MDB2_Result');
|
|
|
|
return ($value instanceof MDB2_Result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
@ -685,15 +647,15 @@ class MDB2
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Tell whether a value is a MDB2 result implementing the common interface
|
|
|
|
* Tell whether a value is a MDB2 result implementing the common interface
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param mixed value to test
|
|
|
|
* @param mixed $value value to test
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return bool whether $value is a MDB2 result implementing the common interface
|
|
|
|
* @return bool whether $value is a MDB2 result implementing the common interface
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function isResultCommon($value)
|
|
|
|
static function isResultCommon($value)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return is_a($value, 'MDB2_Result_Common');
|
|
|
|
return ($value instanceof MDB2_Result_Common);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
@ -710,7 +672,7 @@ class MDB2
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function isStatement($value)
|
|
|
|
function isStatement($value)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return is_a($value, 'MDB2_Statement_Common');
|
|
|
|
return ($value instanceof MDB2_Statement_Common);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
@ -829,7 +791,7 @@ class MDB2
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
* @author Tomas V.V.Cox <cox@idecnet.com>
|
|
|
|
* @author Tomas V.V.Cox <cox@idecnet.com>
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function parseDSN($dsn)
|
|
|
|
static function parseDSN($dsn)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$parsed = $GLOBALS['_MDB2_dsninfo_default'];
|
|
|
|
$parsed = $GLOBALS['_MDB2_dsninfo_default'];
|
|
|
|
|
|
|
|
|
|
|
@ -961,7 +923,7 @@ class MDB2
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function fileExists($file)
|
|
|
|
static function fileExists($file)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// safe_mode does notwork with is_readable()
|
|
|
|
// safe_mode does notwork with is_readable()
|
|
|
|
if (!@ini_get('safe_mode')) {
|
|
|
|
if (!@ini_get('safe_mode')) {
|
|
|
@ -1006,7 +968,7 @@ class MDB2_Error extends PEAR_Error
|
|
|
|
* @param int what error level to use for $mode & PEAR_ERROR_TRIGGER
|
|
|
|
* @param int what error level to use for $mode & PEAR_ERROR_TRIGGER
|
|
|
|
* @param mixed additional debug info, such as the last query
|
|
|
|
* @param mixed additional debug info, such as the last query
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function MDB2_Error($code = MDB2_ERROR, $mode = PEAR_ERROR_RETURN,
|
|
|
|
function __construct($code = MDB2_ERROR, $mode = PEAR_ERROR_RETURN,
|
|
|
|
$level = E_USER_NOTICE, $debuginfo = null, $dummy = null)
|
|
|
|
$level = E_USER_NOTICE, $debuginfo = null, $dummy = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (null === $code) {
|
|
|
|
if (null === $code) {
|
|
|
@ -1355,18 +1317,6 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
$this->db_index = $db_index;
|
|
|
|
$this->db_index = $db_index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
|
|
|
|
// {{{ function MDB2_Driver_Common()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* PHP 4 Constructor
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function MDB2_Driver_Common()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->destructor_registered = false;
|
|
|
|
|
|
|
|
$this->__construct();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
|
// {{{ destructor: function __destruct()
|
|
|
|
// {{{ destructor: function __destruct()
|
|
|
|
|
|
|
|
|
|
|
@ -1501,10 +1451,10 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$err =& PEAR::raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true);
|
|
|
|
$err = PEAR::raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true);
|
|
|
|
if ($err->getMode() !== PEAR_ERROR_RETURN
|
|
|
|
if ($err->getMode() !== PEAR_ERROR_RETURN
|
|
|
|
&& isset($this->nested_transaction_counter) && !$this->has_transaction_error) {
|
|
|
|
&& isset($this->nested_transaction_counter) && !$this->has_transaction_error) {
|
|
|
|
$this->has_transaction_error =& $err;
|
|
|
|
$this->has_transaction_error = $err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $err;
|
|
|
|
return $err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1885,7 +1835,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
|
// {{{ function &loadModule($module, $property = null, $phptype_specific = null)
|
|
|
|
// {{{ function loadModule($module, $property = null, $phptype_specific = null)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* loads a module
|
|
|
|
* loads a module
|
|
|
@ -1901,7 +1851,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function &loadModule($module, $property = null, $phptype_specific = null)
|
|
|
|
function loadModule($module, $property = null, $phptype_specific = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!$property) {
|
|
|
|
if (!$property) {
|
|
|
|
$property = strtolower($module);
|
|
|
|
$property = strtolower($module);
|
|
|
@ -1942,12 +1892,12 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!MDB2::classExists($class_name)) {
|
|
|
|
if (!MDB2::classExists($class_name)) {
|
|
|
|
$err =& $this->raiseError(MDB2_ERROR_LOADMODULE, null, null,
|
|
|
|
$err = $this->raiseError(MDB2_ERROR_LOADMODULE, null, null,
|
|
|
|
"unable to load module '$module' into property '$property'", __FUNCTION__);
|
|
|
|
"unable to load module '$module' into property '$property'", __FUNCTION__);
|
|
|
|
return $err;
|
|
|
|
return $err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->{$property} = new $class_name($this->db_index);
|
|
|
|
$this->{$property} = new $class_name($this->db_index);
|
|
|
|
$this->modules[$module] =& $this->{$property};
|
|
|
|
$this->modules[$module] = $this->{$property};
|
|
|
|
if ($version) {
|
|
|
|
if ($version) {
|
|
|
|
// this will be used in the connect method to determine if the module
|
|
|
|
// this will be used in the connect method to determine if the module
|
|
|
|
// needs to be loaded with a different version if the server
|
|
|
|
// needs to be loaded with a different version if the server
|
|
|
@ -1979,7 +1929,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
$module = $this->options['modules'][$match[1]];
|
|
|
|
$module = $this->options['modules'][$match[1]];
|
|
|
|
$method = strtolower($match[2]).$match[3];
|
|
|
|
$method = strtolower($match[2]).$match[3];
|
|
|
|
if (!isset($this->modules[$module]) || !is_object($this->modules[$module])) {
|
|
|
|
if (!isset($this->modules[$module]) || !is_object($this->modules[$module])) {
|
|
|
|
$result =& $this->loadModule($module);
|
|
|
|
$result = $this->loadModule($module);
|
|
|
|
if (PEAR::isError($result)) {
|
|
|
|
if (PEAR::isError($result)) {
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2439,7 +2389,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function &standaloneQuery($query, $types = null, $is_manip = false)
|
|
|
|
function standaloneQuery($query, $types = null, $is_manip = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$offset = $this->offset;
|
|
|
|
$offset = $this->offset;
|
|
|
|
$limit = $this->limit;
|
|
|
|
$limit = $this->limit;
|
|
|
@ -2451,7 +2401,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
return $connection;
|
|
|
|
return $connection;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$result =& $this->_doQuery($query, $is_manip, $connection, false);
|
|
|
|
$result = $this->_doQuery($query, $is_manip, $connection, false);
|
|
|
|
if (PEAR::isError($result)) {
|
|
|
|
if (PEAR::isError($result)) {
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2460,7 +2410,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
$affected_rows = $this->_affectedRows($connection, $result);
|
|
|
|
$affected_rows = $this->_affectedRows($connection, $result);
|
|
|
|
return $affected_rows;
|
|
|
|
return $affected_rows;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$result =& $this->_wrapResult($result, $types, true, false, $limit, $offset);
|
|
|
|
$result = $this->_wrapResult($result, $types, true, false, $limit, $offset);
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2498,7 +2448,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access protected
|
|
|
|
* @access protected
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function &_doQuery($query, $is_manip = false, $connection = null, $database_name = null)
|
|
|
|
function _doQuery($query, $is_manip = false, $connection = null, $database_name = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->last_query = $query;
|
|
|
|
$this->last_query = $query;
|
|
|
|
$result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre'));
|
|
|
|
$result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre'));
|
|
|
@ -2508,7 +2458,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$query = $result;
|
|
|
|
$query = $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$err =& $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
|
|
|
$err = $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
|
|
|
'method not implemented', __FUNCTION__);
|
|
|
|
'method not implemented', __FUNCTION__);
|
|
|
|
return $err;
|
|
|
|
return $err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2544,7 +2494,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function &exec($query)
|
|
|
|
function exec($query)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$offset = $this->offset;
|
|
|
|
$offset = $this->offset;
|
|
|
|
$limit = $this->limit;
|
|
|
|
$limit = $this->limit;
|
|
|
@ -2556,7 +2506,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
return $connection;
|
|
|
|
return $connection;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$result =& $this->_doQuery($query, true, $connection, $this->database_name);
|
|
|
|
$result = $this->_doQuery($query, true, $connection, $this->database_name);
|
|
|
|
if (PEAR::isError($result)) {
|
|
|
|
if (PEAR::isError($result)) {
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2581,7 +2531,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function &query($query, $types = null, $result_class = true, $result_wrap_class = false)
|
|
|
|
function query($query, $types = null, $result_class = true, $result_wrap_class = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$offset = $this->offset;
|
|
|
|
$offset = $this->offset;
|
|
|
|
$limit = $this->limit;
|
|
|
|
$limit = $this->limit;
|
|
|
@ -2593,17 +2543,17 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
return $connection;
|
|
|
|
return $connection;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$result =& $this->_doQuery($query, false, $connection, $this->database_name);
|
|
|
|
$result = $this->_doQuery($query, false, $connection, $this->database_name);
|
|
|
|
if (PEAR::isError($result)) {
|
|
|
|
if (PEAR::isError($result)) {
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$result =& $this->_wrapResult($result, $types, $result_class, $result_wrap_class, $limit, $offset);
|
|
|
|
$result = $this->_wrapResult($result, $types, $result_class, $result_wrap_class, $limit, $offset);
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
|
// {{{ function &_wrapResult($result_resource, $types = array(), $result_class = true, $result_wrap_class = false, $limit = null, $offset = null)
|
|
|
|
// {{{ function _wrapResult($result_resource, $types = array(), $result_class = true, $result_wrap_class = false, $limit = null, $offset = null)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* wrap a result set into the correct class
|
|
|
|
* wrap a result set into the correct class
|
|
|
@ -2620,7 +2570,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access protected
|
|
|
|
* @access protected
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function &_wrapResult($result_resource, $types = array(), $result_class = true,
|
|
|
|
function _wrapResult($result_resource, $types = array(), $result_class = true,
|
|
|
|
$result_wrap_class = false, $limit = null, $offset = null)
|
|
|
|
$result_wrap_class = false, $limit = null, $offset = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ($types === true) {
|
|
|
|
if ($types === true) {
|
|
|
@ -2647,13 +2597,13 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
if ($result_class) {
|
|
|
|
if ($result_class) {
|
|
|
|
$class_name = sprintf($result_class, $this->phptype);
|
|
|
|
$class_name = sprintf($result_class, $this->phptype);
|
|
|
|
if (!MDB2::classExists($class_name)) {
|
|
|
|
if (!MDB2::classExists($class_name)) {
|
|
|
|
$err =& $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
|
|
|
$err = $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
|
|
|
'result class does not exist '.$class_name, __FUNCTION__);
|
|
|
|
'result class does not exist '.$class_name, __FUNCTION__);
|
|
|
|
return $err;
|
|
|
|
return $err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$result = new $class_name($this, $result_resource, $limit, $offset);
|
|
|
|
$result = new $class_name($this, $result_resource, $limit, $offset);
|
|
|
|
if (!MDB2::isResultCommon($result)) {
|
|
|
|
if (!MDB2::isResultCommon($result)) {
|
|
|
|
$err =& $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
|
|
|
$err = $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
|
|
|
'result class is not extended from MDB2_Result_Common', __FUNCTION__);
|
|
|
|
'result class is not extended from MDB2_Result_Common', __FUNCTION__);
|
|
|
|
return $err;
|
|
|
|
return $err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2670,7 +2620,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($result_wrap_class) {
|
|
|
|
if ($result_wrap_class) {
|
|
|
|
if (!MDB2::classExists($result_wrap_class)) {
|
|
|
|
if (!MDB2::classExists($result_wrap_class)) {
|
|
|
|
$err =& $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
|
|
|
$err = $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
|
|
|
'result wrap class does not exist '.$result_wrap_class, __FUNCTION__);
|
|
|
|
'result wrap class does not exist '.$result_wrap_class, __FUNCTION__);
|
|
|
|
return $err;
|
|
|
|
return $err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2881,7 +2831,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
|
|
|
|
|
|
|
|
$condition = ' WHERE '.implode(' AND ', $condition);
|
|
|
|
$condition = ' WHERE '.implode(' AND ', $condition);
|
|
|
|
$query = 'DELETE FROM ' . $this->quoteIdentifier($table, true) . $condition;
|
|
|
|
$query = 'DELETE FROM ' . $this->quoteIdentifier($table, true) . $condition;
|
|
|
|
$result =& $this->_doQuery($query, true, $connection);
|
|
|
|
$result = $this->_doQuery($query, true, $connection);
|
|
|
|
if (!PEAR::isError($result)) {
|
|
|
|
if (!PEAR::isError($result)) {
|
|
|
|
$affected_rows = $this->_affectedRows($connection, $result);
|
|
|
|
$affected_rows = $this->_affectedRows($connection, $result);
|
|
|
|
$insert = '';
|
|
|
|
$insert = '';
|
|
|
@ -2890,7 +2840,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$values = implode(', ', $values);
|
|
|
|
$values = implode(', ', $values);
|
|
|
|
$query = 'INSERT INTO '. $this->quoteIdentifier($table, true) . "($insert) VALUES ($values)";
|
|
|
|
$query = 'INSERT INTO '. $this->quoteIdentifier($table, true) . "($insert) VALUES ($values)";
|
|
|
|
$result =& $this->_doQuery($query, true, $connection);
|
|
|
|
$result = $this->_doQuery($query, true, $connection);
|
|
|
|
if (!PEAR::isError($result)) {
|
|
|
|
if (!PEAR::isError($result)) {
|
|
|
|
$affected_rows += $this->_affectedRows($connection, $result);;
|
|
|
|
$affected_rows += $this->_affectedRows($connection, $result);;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2937,7 +2887,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
* @see bindParam, execute
|
|
|
|
* @see bindParam, execute
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function &prepare($query, $types = null, $result_types = null, $lobs = array())
|
|
|
|
function prepare($query, $types = null, $result_types = null, $lobs = array())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$is_manip = ($result_types === MDB2_PREPARE_MANIP);
|
|
|
|
$is_manip = ($result_types === MDB2_PREPARE_MANIP);
|
|
|
|
$offset = $this->offset;
|
|
|
|
$offset = $this->offset;
|
|
|
@ -3000,7 +2950,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
$regexp = '/^.{'.($position+1).'}('.$this->options['bindname_format'].').*$/s';
|
|
|
|
$regexp = '/^.{'.($position+1).'}('.$this->options['bindname_format'].').*$/s';
|
|
|
|
$parameter = preg_replace($regexp, '\\1', $query);
|
|
|
|
$parameter = preg_replace($regexp, '\\1', $query);
|
|
|
|
if ($parameter === '') {
|
|
|
|
if ($parameter === '') {
|
|
|
|
$err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null,
|
|
|
|
$err = $this->raiseError(MDB2_ERROR_SYNTAX, null, null,
|
|
|
|
'named parameter name must match "bindname_format" option', __FUNCTION__);
|
|
|
|
'named parameter name must match "bindname_format" option', __FUNCTION__);
|
|
|
|
return $err;
|
|
|
|
return $err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3045,7 +2995,8 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function _skipDelimitedStrings($query, $position, $p_position)
|
|
|
|
function _skipDelimitedStrings($query, $position, $p_position)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$ignores = $this->string_quoting;
|
|
|
|
$ignores = array();
|
|
|
|
|
|
|
|
$ignores[] = $this->string_quoting;
|
|
|
|
$ignores[] = $this->identifier_quoting;
|
|
|
|
$ignores[] = $this->identifier_quoting;
|
|
|
|
$ignores = array_merge($ignores, $this->sql_comments);
|
|
|
|
$ignores = array_merge($ignores, $this->sql_comments);
|
|
|
|
|
|
|
|
|
|
|
@ -3058,7 +3009,7 @@ class MDB2_Driver_Common extends PEAR
|
|
|
|
if ($ignore['end'] === "\n") {
|
|
|
|
if ($ignore['end'] === "\n") {
|
|
|
|
$end_quote = strlen($query) - 1;
|
|
|
|
$end_quote = strlen($query) - 1;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null,
|
|
|
|
$err = $this->raiseError(MDB2_ERROR_SYNTAX, null, null,
|
|
|
|
'query with an unterminated text string specified', __FUNCTION__);
|
|
|
|
'query with an unterminated text string specified', __FUNCTION__);
|
|
|
|
return $err;
|
|
|
|
return $err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3443,30 +3394,19 @@ class MDB2_Result_Common extends MDB2_Result
|
|
|
|
var $column_names;
|
|
|
|
var $column_names;
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
|
// {{{ constructor: function __construct(&$db, &$result, $limit = 0, $offset = 0)
|
|
|
|
// {{{ constructor: function __construct($db, &$result, $limit = 0, $offset = 0)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
* Constructor
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function __construct(&$db, &$result, $limit = 0, $offset = 0)
|
|
|
|
function __construct($db, &$result, $limit = 0, $offset = 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->db =& $db;
|
|
|
|
$this->db = $db;
|
|
|
|
$this->result =& $result;
|
|
|
|
$this->result = $result;
|
|
|
|
$this->offset = $offset;
|
|
|
|
$this->offset = $offset;
|
|
|
|
$this->limit = max(0, $limit - 1);
|
|
|
|
$this->limit = max(0, $limit - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
|
|
|
|
// {{{ function MDB2_Result_Common(&$db, &$result, $limit = 0, $offset = 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* PHP 4 Constructor
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function MDB2_Result_Common(&$db, &$result, $limit = 0, $offset = 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->__construct($db, $result, $limit, $offset);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
|
// {{{ function setResultTypes($types)
|
|
|
|
// {{{ function setResultTypes($types)
|
|
|
|
|
|
|
|
|
|
|
@ -3543,9 +3483,9 @@ class MDB2_Result_Common extends MDB2_Result
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function &fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null)
|
|
|
|
function fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$err =& $this->db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
|
|
|
$err = $this->db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
|
|
|
'method not implemented', __FUNCTION__);
|
|
|
|
'method not implemented', __FUNCTION__);
|
|
|
|
return $err;
|
|
|
|
return $err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3925,19 +3865,6 @@ class MDB2_Row
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
|
|
|
|
// {{{ function MDB2_Row(&$row)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* PHP 4 Constructor
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param resource row data as array
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function MDB2_Row(&$row)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->__construct($row);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -3966,15 +3893,15 @@ class MDB2_Statement_Common
|
|
|
|
var $is_manip;
|
|
|
|
var $is_manip;
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
|
// {{{ constructor: function __construct(&$db, &$statement, $positions, $query, $types, $result_types, $is_manip = false, $limit = null, $offset = null)
|
|
|
|
// {{{ constructor: function __construct($db, $statement, $positions, $query, $types, $result_types, $is_manip = false, $limit = null, $offset = null)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
* Constructor
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function __construct(&$db, &$statement, $positions, $query, $types, $result_types, $is_manip = false, $limit = null, $offset = null)
|
|
|
|
function __construct($db, $statement, $positions, $query, $types, $result_types, $is_manip = false, $limit = null, $offset = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->db =& $db;
|
|
|
|
$this->db = $db;
|
|
|
|
$this->statement =& $statement;
|
|
|
|
$this->statement = $statement;
|
|
|
|
$this->positions = $positions;
|
|
|
|
$this->positions = $positions;
|
|
|
|
$this->query = $query;
|
|
|
|
$this->query = $query;
|
|
|
|
$this->types = (array)$types;
|
|
|
|
$this->types = (array)$types;
|
|
|
@ -3984,17 +3911,6 @@ class MDB2_Statement_Common
|
|
|
|
$this->offset = $offset;
|
|
|
|
$this->offset = $offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
|
|
|
|
// {{{ function MDB2_Statement_Common(&$db, &$statement, $positions, $query, $types, $result_types, $is_manip = false, $limit = null, $offset = null)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* PHP 4 Constructor
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function MDB2_Statement_Common(&$db, &$statement, $positions, $query, $types, $result_types, $is_manip = false, $limit = null, $offset = null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->__construct($db, $statement, $positions, $query, $types, $result_types, $is_manip, $limit, $offset);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
|
// {{{ function bindValue($parameter, &$value, $type = null)
|
|
|
|
// {{{ function bindValue($parameter, &$value, $type = null)
|
|
|
|
|
|
|
|
|
|
|
@ -4141,7 +4057,7 @@ class MDB2_Statement_Common
|
|
|
|
* a MDB2 error on failure
|
|
|
|
* a MDB2 error on failure
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function &execute($values = null, $result_class = true, $result_wrap_class = false)
|
|
|
|
function execute($values = null, $result_class = true, $result_wrap_class = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (null === $this->positions) {
|
|
|
|
if (null === $this->positions) {
|
|
|
|
return $this->db->raiseError(MDB2_ERROR, null, null,
|
|
|
|
return $this->db->raiseError(MDB2_ERROR, null, null,
|
|
|
@ -4156,12 +4072,12 @@ class MDB2_Statement_Common
|
|
|
|
'Binding Values failed with message: ' . $err->getMessage(), __FUNCTION__);
|
|
|
|
'Binding Values failed with message: ' . $err->getMessage(), __FUNCTION__);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$result =& $this->_execute($result_class, $result_wrap_class);
|
|
|
|
$result = $this->_execute($result_class, $result_wrap_class);
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
|
// {{{ function &_execute($result_class = true, $result_wrap_class = false)
|
|
|
|
// {{{ function _execute($result_class = true, $result_wrap_class = false)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Execute a prepared query statement helper method.
|
|
|
|
* Execute a prepared query statement helper method.
|
|
|
@ -4173,7 +4089,7 @@ class MDB2_Statement_Common
|
|
|
|
* a MDB2 error on failure
|
|
|
|
* a MDB2 error on failure
|
|
|
|
* @access private
|
|
|
|
* @access private
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function &_execute($result_class = true, $result_wrap_class = false)
|
|
|
|
function _execute($result_class = true, $result_wrap_class = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->last_query = $this->query;
|
|
|
|
$this->last_query = $this->query;
|
|
|
|
$query = '';
|
|
|
|
$query = '';
|
|
|
@ -4204,7 +4120,7 @@ class MDB2_Statement_Common
|
|
|
|
if ($this->is_manip) {
|
|
|
|
if ($this->is_manip) {
|
|
|
|
$result = $this->db->exec($query);
|
|
|
|
$result = $this->db->exec($query);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$result =& $this->db->query($query, $this->result_types, $result_class, $result_wrap_class);
|
|
|
|
$result = $this->db->query($query, $this->result_types, $result_class, $result_wrap_class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -4277,18 +4193,7 @@ class MDB2_Module_Common
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
// }}}
|
|
|
|
// {{{ function MDB2_Module_Common($db_index)
|
|
|
|
// {{{ function getDBInstance()
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* PHP 4 Constructor
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function MDB2_Module_Common($db_index)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->__construct($db_index);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
|
|
|
|
// {{{ function &getDBInstance()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Get the instance of MDB2 associated with the module instance
|
|
|
|
* Get the instance of MDB2 associated with the module instance
|
|
|
@ -4297,12 +4202,12 @@ class MDB2_Module_Common
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function &getDBInstance()
|
|
|
|
function getDBInstance()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) {
|
|
|
|
if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) {
|
|
|
|
$result =& $GLOBALS['_MDB2_databases'][$this->db_index];
|
|
|
|
$result = $GLOBALS['_MDB2_databases'][$this->db_index];
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$result =& MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
|
|
|
$result = MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
|
|
|
'could not find MDB2 instance');
|
|
|
|
'could not find MDB2 instance');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|