mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Mise jour de Pear MDB2
This commit is contained in:
parent
57d530f142
commit
4ebb2bc445
|
|
@ -282,7 +282,7 @@ class MDB2
|
|||
if (is_array($options)) {
|
||||
foreach ($options as $option => $value) {
|
||||
$test = $db->setOption($option, $value);
|
||||
if (PEAR::isError($test)) {
|
||||
if (DOLIPEAR::isError($test)) {
|
||||
return $test;
|
||||
}
|
||||
}
|
||||
|
|
@ -384,14 +384,14 @@ class MDB2
|
|||
|
||||
$debug = (!empty($options['debug']));
|
||||
$err = MDB2::loadClass($class_name, $debug);
|
||||
if (PEAR::isError($err)) {
|
||||
if (DOLIPEAR::isError($err)) {
|
||||
return $err;
|
||||
}
|
||||
|
||||
$db =& new $class_name();
|
||||
$db->setDSN($dsninfo);
|
||||
$err = MDB2::setOptions($db, $options);
|
||||
if (PEAR::isError($err)) {
|
||||
if (DOLIPEAR::isError($err)) {
|
||||
return $err;
|
||||
}
|
||||
|
||||
|
|
@ -432,12 +432,12 @@ class MDB2
|
|||
function &connect($dsn, $options = false)
|
||||
{
|
||||
$db =& MDB2::factory($dsn, $options);
|
||||
if (PEAR::isError($db)) {
|
||||
if (DOLIPEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$err = $db->connect();
|
||||
if (PEAR::isError($err)) {
|
||||
if (DOLIPEAR::isError($err)) {
|
||||
$dsn = $db->getDSN('string', 'xxx');
|
||||
$db->disconnect();
|
||||
$err->addUserInfo($dsn);
|
||||
|
|
@ -548,7 +548,7 @@ class MDB2
|
|||
|
||||
/**
|
||||
* This method is used to communicate an error and invoke error
|
||||
* callbacks etc. Basically a wrapper for PEAR::raiseError
|
||||
* callbacks etc. Basically a wrapper for DOLIPEAR::raiseError
|
||||
* without the message string.
|
||||
*
|
||||
* @param mixed int error code
|
||||
|
|
@ -572,7 +572,7 @@ class MDB2
|
|||
*/
|
||||
function &raiseError($code = null, $mode = null, $options = null, $userinfo = null)
|
||||
{
|
||||
$err =& PEAR::raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true);
|
||||
$err =& DOLIPEAR::raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true);
|
||||
return $err;
|
||||
}
|
||||
|
||||
|
|
@ -741,7 +741,7 @@ class MDB2
|
|||
return $errorMessages;
|
||||
}
|
||||
|
||||
if (PEAR::isError($value)) {
|
||||
if (DOLIPEAR::isError($value)) {
|
||||
$value = $value->getCode();
|
||||
}
|
||||
|
||||
|
|
@ -1384,7 +1384,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
|
||||
/**
|
||||
* This method is used to communicate an error and invoke error
|
||||
* callbacks etc. Basically a wrapper for PEAR::raiseError
|
||||
* callbacks etc. Basically a wrapper for DOLIPEAR::raiseError
|
||||
* without the message string.
|
||||
*
|
||||
* @param mixed integer error code, or a PEAR error object (all other
|
||||
|
|
@ -1409,8 +1409,8 @@ class MDB2_Driver_Common extends PEAR
|
|||
{
|
||||
$userinfo = "[Error message: $userinfo]\n";
|
||||
// The error is yet a MDB2 error object
|
||||
if (PEAR::isError($code)) {
|
||||
// because we use the static PEAR::raiseError, our global
|
||||
if (DOLIPEAR::isError($code)) {
|
||||
// because we use the static DOLIPEAR::raiseError, our global
|
||||
// handler should be used if it is set
|
||||
if (is_null($mode) && !empty($this->_default_error_mode)) {
|
||||
$mode = $this->_default_error_mode;
|
||||
|
|
@ -1440,7 +1440,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
}
|
||||
}
|
||||
|
||||
$err =& PEAR::raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true);
|
||||
$err =& DOLIPEAR::raiseError(null, $code, $mode, $options, $userinfo, 'MDB2_Error', true);
|
||||
if ($err->getMode() !== PEAR_ERROR_RETURN
|
||||
&& isset($this->nested_transaction_counter) && !$this->has_transaction_error) {
|
||||
$this->has_transaction_error =& $err;
|
||||
|
|
@ -1734,7 +1734,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
function getConnection()
|
||||
{
|
||||
$result = $this->connect();
|
||||
if (PEAR::isError($result)) {
|
||||
if (DOLIPEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
return $this->connection;
|
||||
|
|
@ -1860,7 +1860,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
}
|
||||
|
||||
$err = MDB2::loadClass($class_name, $this->getOption('debug'));
|
||||
if (PEAR::isError($err)) {
|
||||
if (DOLIPEAR::isError($err)) {
|
||||
return $err;
|
||||
}
|
||||
|
||||
|
|
@ -1871,7 +1871,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
if ($class_name != $class_name_new) {
|
||||
$class_name = $class_name_new;
|
||||
$err = MDB2::loadClass($class_name, $this->getOption('debug'));
|
||||
if (PEAR::isError($err)) {
|
||||
if (DOLIPEAR::isError($err)) {
|
||||
return $err;
|
||||
}
|
||||
}
|
||||
|
|
@ -1917,7 +1917,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
$method = strtolower($match[2]).$match[3];
|
||||
if (!isset($this->modules[$module]) || !is_object($this->modules[$module])) {
|
||||
$result =& $this->loadModule($module);
|
||||
if (PEAR::isError($result)) {
|
||||
if (DOLIPEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
@ -2104,7 +2104,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
if ($this->supports('savepoints') && $savepoint) {
|
||||
if ($force_rollback || $this->has_transaction_error) {
|
||||
$result = $this->rollback($savepoint);
|
||||
if (!PEAR::isError($result)) {
|
||||
if (!DOLIPEAR::isError($result)) {
|
||||
$result = false;
|
||||
$this->has_transaction_error = false;
|
||||
}
|
||||
|
|
@ -2125,7 +2125,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
if ($this->in_transaction) {
|
||||
if ($force_rollback || $this->has_transaction_error) {
|
||||
$result = $this->rollback();
|
||||
if (!PEAR::isError($result)) {
|
||||
if (!DOLIPEAR::isError($result)) {
|
||||
$result = false;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2366,12 +2366,12 @@ class MDB2_Driver_Common extends PEAR
|
|||
$query = $this->_modifyQuery($query, $is_manip, $limit, $offset);
|
||||
|
||||
$connection = $this->getConnection();
|
||||
if (PEAR::isError($connection)) {
|
||||
if (DOLIPEAR::isError($connection)) {
|
||||
return $connection;
|
||||
}
|
||||
|
||||
$result =& $this->_doQuery($query, $is_manip, $connection, false);
|
||||
if (PEAR::isError($result)) {
|
||||
if (DOLIPEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
@ -2422,7 +2422,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
$this->last_query = $query;
|
||||
$result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre'));
|
||||
if ($result) {
|
||||
if (PEAR::isError($result)) {
|
||||
if (DOLIPEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
$query = $result;
|
||||
|
|
@ -2471,12 +2471,12 @@ class MDB2_Driver_Common extends PEAR
|
|||
$query = $this->_modifyQuery($query, true, $limit, $offset);
|
||||
|
||||
$connection = $this->getConnection();
|
||||
if (PEAR::isError($connection)) {
|
||||
if (DOLIPEAR::isError($connection)) {
|
||||
return $connection;
|
||||
}
|
||||
|
||||
$result =& $this->_doQuery($query, true, $connection, $this->database_name);
|
||||
if (PEAR::isError($result)) {
|
||||
if (DOLIPEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
@ -2508,12 +2508,12 @@ class MDB2_Driver_Common extends PEAR
|
|||
$query = $this->_modifyQuery($query, false, $limit, $offset);
|
||||
|
||||
$connection = $this->getConnection();
|
||||
if (PEAR::isError($connection)) {
|
||||
if (DOLIPEAR::isError($connection)) {
|
||||
return $connection;
|
||||
}
|
||||
|
||||
$result =& $this->_doQuery($query, false, $connection, $this->database_name);
|
||||
if (PEAR::isError($result)) {
|
||||
if (DOLIPEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
@ -2546,7 +2546,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
if ($this->supports('result_introspection')) {
|
||||
$this->loadModule('Reverse', null, true);
|
||||
$tableInfo = $this->reverse->tableInfo($result);
|
||||
if (PEAR::isError($tableInfo)) {
|
||||
if (DOLIPEAR::isError($tableInfo)) {
|
||||
return $tableInfo;
|
||||
}
|
||||
$types = array();
|
||||
|
|
@ -2578,7 +2578,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
}
|
||||
if (!empty($types)) {
|
||||
$err = $result->setResultTypes($types);
|
||||
if (PEAR::isError($err)) {
|
||||
if (DOLIPEAR::isError($err)) {
|
||||
$result->free();
|
||||
return $err;
|
||||
}
|
||||
|
|
@ -2679,7 +2679,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
}
|
||||
|
||||
$col = $this->queryCol($query, $type);
|
||||
if (PEAR::isError($col)) {
|
||||
if (DOLIPEAR::isError($col)) {
|
||||
return $col;
|
||||
}
|
||||
if (!is_array($col) || count($col) == 0) {
|
||||
|
|
@ -2790,38 +2790,38 @@ class MDB2_Driver_Common extends PEAR
|
|||
|
||||
$result = null;
|
||||
$in_transaction = $this->in_transaction;
|
||||
if (!$in_transaction && PEAR::isError($result = $this->beginTransaction())) {
|
||||
if (!$in_transaction && DOLIPEAR::isError($result = $this->beginTransaction())) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$connection = $this->getConnection();
|
||||
if (PEAR::isError($connection)) {
|
||||
if (DOLIPEAR::isError($connection)) {
|
||||
return $connection;
|
||||
}
|
||||
|
||||
$condition = ' WHERE '.implode(' AND ', $condition);
|
||||
$query = "DELETE FROM $table$condition";
|
||||
$result =& $this->_doQuery($query, true, $connection);
|
||||
if (!PEAR::isError($result)) {
|
||||
if (!DOLIPEAR::isError($result)) {
|
||||
$affected_rows = $this->_affectedRows($connection, $result);
|
||||
$insert = implode(', ', array_keys($values));
|
||||
$values = implode(', ', $values);
|
||||
$query = "INSERT INTO $table ($insert) VALUES ($values)";
|
||||
$result =& $this->_doQuery($query, true, $connection);
|
||||
if (!PEAR::isError($result)) {
|
||||
if (!DOLIPEAR::isError($result)) {
|
||||
$affected_rows += $this->_affectedRows($connection, $result);;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$in_transaction) {
|
||||
if (PEAR::isError($result)) {
|
||||
if (DOLIPEAR::isError($result)) {
|
||||
$this->rollback();
|
||||
} else {
|
||||
$result = $this->commit();
|
||||
}
|
||||
}
|
||||
|
||||
if (PEAR::isError($result)) {
|
||||
if (DOLIPEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
@ -2861,7 +2861,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
$this->offset = $this->limit = 0;
|
||||
$result = $this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'pre'));
|
||||
if ($result) {
|
||||
if (PEAR::isError($result)) {
|
||||
if (DOLIPEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
$query = $result;
|
||||
|
|
@ -2891,7 +2891,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
}
|
||||
|
||||
$new_pos = $this->_skipDelimitedStrings($query, $position, $p_position);
|
||||
if (PEAR::isError($new_pos)) {
|
||||
if (DOLIPEAR::isError($new_pos)) {
|
||||
return $new_pos;
|
||||
}
|
||||
if ($new_pos != $position) {
|
||||
|
|
@ -3010,7 +3010,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
function quote($value, $type = null, $quote = true, $escape_wildcards = false)
|
||||
{
|
||||
$result = $this->loadModule('Datatype', null, true);
|
||||
if (PEAR::isError($result)) {
|
||||
if (DOLIPEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
@ -3036,7 +3036,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
function getDeclaration($type, $name, $field)
|
||||
{
|
||||
$result = $this->loadModule('Datatype', null, true);
|
||||
if (PEAR::isError($result)) {
|
||||
if (DOLIPEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
return $this->datatype->getDeclaration($type, $name, $field);
|
||||
|
|
@ -3058,7 +3058,7 @@ class MDB2_Driver_Common extends PEAR
|
|||
function compareDefinition($current, $previous)
|
||||
{
|
||||
$result = $this->loadModule('Datatype', null, true);
|
||||
if (PEAR::isError($result)) {
|
||||
if (DOLIPEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
return $this->datatype->compareDefinition($current, $previous);
|
||||
|
|
@ -3407,11 +3407,11 @@ class MDB2_Result_Common extends MDB2_Result
|
|||
function setResultTypes($types)
|
||||
{
|
||||
$load = $this->db->loadModule('Datatype', null, true);
|
||||
if (PEAR::isError($load)) {
|
||||
if (DOLIPEAR::isError($load)) {
|
||||
return $load;
|
||||
}
|
||||
$types = $this->db->datatype->checkResultTypes($types);
|
||||
if (PEAR::isError($types)) {
|
||||
if (DOLIPEAR::isError($types)) {
|
||||
return $types;
|
||||
}
|
||||
$this->types = $types;
|
||||
|
|
@ -3480,7 +3480,7 @@ class MDB2_Result_Common extends MDB2_Result
|
|||
{
|
||||
$fetchmode = is_numeric($colnum) ? MDB2_FETCHMODE_ORDERED : MDB2_FETCHMODE_ASSOC;
|
||||
$row = $this->fetchRow($fetchmode, $rownum);
|
||||
if (!is_array($row) || PEAR::isError($row)) {
|
||||
if (!is_array($row) || DOLIPEAR::isError($row)) {
|
||||
return $row;
|
||||
}
|
||||
if (!array_key_exists($colnum, $row)) {
|
||||
|
|
@ -3516,7 +3516,7 @@ class MDB2_Result_Common extends MDB2_Result
|
|||
$column[] = $row[$colnum];
|
||||
} while (is_array($row = $this->fetchRow($fetchmode)));
|
||||
}
|
||||
if (PEAR::isError($row)) {
|
||||
if (DOLIPEAR::isError($row)) {
|
||||
return $row;
|
||||
}
|
||||
return $column;
|
||||
|
|
@ -3553,7 +3553,7 @@ class MDB2_Result_Common extends MDB2_Result
|
|||
{
|
||||
$all = array();
|
||||
$row = $this->fetchRow($fetchmode);
|
||||
if (PEAR::isError($row)) {
|
||||
if (DOLIPEAR::isError($row)) {
|
||||
return $row;
|
||||
} elseif (!$row) {
|
||||
return $all;
|
||||
|
|
@ -3676,7 +3676,7 @@ class MDB2_Result_Common extends MDB2_Result
|
|||
{
|
||||
if (!isset($this->column_names)) {
|
||||
$result = $this->_getColumnNames();
|
||||
if (PEAR::isError($result)) {
|
||||
if (DOLIPEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
$this->column_names = $result;
|
||||
|
|
@ -3964,7 +3964,7 @@ class MDB2_Statement_Common
|
|||
$parameters = array_keys($values);
|
||||
foreach ($parameters as $key => $parameter) {
|
||||
$err = $this->bindValue($parameter, $values[$parameter], $types[$key]);
|
||||
if (PEAR::isError($err)) {
|
||||
if (DOLIPEAR::isError($err)) {
|
||||
return $err;
|
||||
}
|
||||
}
|
||||
|
|
@ -4025,7 +4025,7 @@ class MDB2_Statement_Common
|
|||
$parameters = array_keys($values);
|
||||
foreach ($parameters as $key => $parameter) {
|
||||
$err = $this->bindParam($parameter, $values[$parameter], $types[$key]);
|
||||
if (PEAR::isError($err)) {
|
||||
if (DOLIPEAR::isError($err)) {
|
||||
return $err;
|
||||
}
|
||||
}
|
||||
|
|
@ -4058,7 +4058,7 @@ class MDB2_Statement_Common
|
|||
$values = (array)$values;
|
||||
if (!empty($values)) {
|
||||
$err = $this->bindValueArray($values);
|
||||
if (PEAR::isError($err)) {
|
||||
if (DOLIPEAR::isError($err)) {
|
||||
return $this->db->raiseError(MDB2_ERROR, null, null,
|
||||
'Binding Values failed with message: ' . $err->getMessage(), __FUNCTION__);
|
||||
}
|
||||
|
|
@ -4097,7 +4097,7 @@ class MDB2_Statement_Common
|
|||
} else {
|
||||
$type = !empty($this->types[$parameter]) ? $this->types[$parameter] : null;
|
||||
$value_quoted = $this->db->quote($value, $type);
|
||||
if (PEAR::isError($value_quoted)) {
|
||||
if (DOLIPEAR::isError($value_quoted)) {
|
||||
return $value_quoted;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user