summaryrefslogtreecommitdiff
path: root/program/lib/DB/mysql.php
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2008-05-12 12:19:32 +0000
committeralecpl <alec@alec.pl>2008-05-12 12:19:32 +0000
commite5deaae52880e7ddb7efab0b190e5f5c750f55c4 (patch)
treef3a45e99480c5818dde1f939fc75e11bce8bb3d5 /program/lib/DB/mysql.php
parenta6f90e1b2bea6602f7056986ee8dbd59afeee90c (diff)
- Updated PEAR::DB package to version 1.7.13
Diffstat (limited to 'program/lib/DB/mysql.php')
-rw-r--r--program/lib/DB/mysql.php39
1 files changed, 25 insertions, 14 deletions
diff --git a/program/lib/DB/mysql.php b/program/lib/DB/mysql.php
index 5b737b606..91572e14a 100644
--- a/program/lib/DB/mysql.php
+++ b/program/lib/DB/mysql.php
@@ -18,7 +18,7 @@
* @package DB
* @author Stig Bakken <ssb@php.net>
* @author Daniel Convissor <danielc@php.net>
- * @copyright 1997-2005 The PHP Group
+ * @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id$
* @link http://pear.php.net/package/DB
@@ -39,9 +39,9 @@ require_once 'DB/common.php';
* @package DB
* @author Stig Bakken <ssb@php.net>
* @author Daniel Convissor <danielc@php.net>
- * @copyright 1997-2005 The PHP Group
+ * @copyright 1997-2007 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: @package_version@
+ * @version Release: 1.7.13
* @link http://pear.php.net/package/DB
*/
class DB_mysql extends DB_common
@@ -111,6 +111,9 @@ class DB_mysql extends DB_common
1146 => DB_ERROR_NOSUCHTABLE,
1216 => DB_ERROR_CONSTRAINT,
1217 => DB_ERROR_CONSTRAINT,
+ 1356 => DB_ERROR_DIVZERO,
+ 1451 => DB_ERROR_CONSTRAINT,
+ 1452 => DB_ERROR_CONSTRAINT,
);
/**
@@ -236,10 +239,10 @@ class DB_mysql extends DB_common
$this->connection = @call_user_func_array($connect_function,
$params);
} else {
- ini_set('track_errors', 1);
+ @ini_set('track_errors', 1);
$this->connection = @call_user_func_array($connect_function,
$params);
- ini_set('track_errors', $ini);
+ @ini_set('track_errors', $ini);
}
if (!$this->connection) {
@@ -297,7 +300,7 @@ class DB_mysql extends DB_common
*/
function simpleQuery($query)
{
- $ismanip = DB::isManip($query);
+ $ismanip = $this->_checkManip($query);
$this->last_query = $query;
$query = $this->modifyQuery($query);
if ($this->_db) {
@@ -419,7 +422,7 @@ class DB_mysql extends DB_common
*/
function freeResult($result)
{
- return @mysql_free_result($result);
+ return is_resource($result) ? mysql_free_result($result) : false;
}
// }}}
@@ -555,7 +558,7 @@ class DB_mysql extends DB_common
*/
function affectedRows()
{
- if (DB::isManip($this->last_query)) {
+ if ($this->_last_query_manip) {
return @mysql_affected_rows($this->connection);
} else {
return 0;
@@ -752,9 +755,10 @@ class DB_mysql extends DB_common
/**
* Quotes a string so it can be safely used as a table or column name
+ * (WARNING: using names that require this is a REALLY BAD IDEA)
*
- * MySQL can't handle the backtick character (<kbd>`</kbd>) in
- * table or column names.
+ * WARNING: Older versions of MySQL can't handle the backtick
+ * character (<kbd>`</kbd>) in table or column names.
*
* @param string $str identifier name to be quoted
*
@@ -765,7 +769,7 @@ class DB_mysql extends DB_common
*/
function quoteIdentifier($str)
{
- return '`' . $str . '`';
+ return '`' . str_replace('`', '``', $str) . '`';
}
// }}}
@@ -852,7 +856,7 @@ class DB_mysql extends DB_common
*/
function modifyLimitQuery($query, $from, $count, $params = array())
{
- if (DB::isManip($query)) {
+ if (DB::isManip($query) || $this->_next_query_manip) {
return $query . " LIMIT $count";
} else {
return $query . " LIMIT $from, $count";
@@ -928,12 +932,19 @@ class DB_mysql extends DB_common
function tableInfo($result, $mode = null)
{
if (is_string($result)) {
+ // Fix for bug #11580.
+ if ($this->_db) {
+ if (!@mysql_select_db($this->_db, $this->connection)) {
+ return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED);
+ }
+ }
+
/*
* Probably received a table name.
* Create a result resource identifier.
*/
- $id = @mysql_list_fields($this->dsn['database'],
- $result, $this->connection);
+ $id = @mysql_query("SELECT * FROM $result LIMIT 0",
+ $this->connection);
$got_string = true;
} elseif (isset($result->result)) {
/*