PMCORE-3876 Check Backward Incompatible Changes, specially "String to Number Comparison"
This commit is contained in:
@@ -11,8 +11,4 @@ spl_autoload_register(function($class)
|
||||
return HTMLPurifier_Bootstrap::autoload($class);
|
||||
});
|
||||
|
||||
if (ini_get('zend.ze1_compatibility_mode')) {
|
||||
trigger_error("HTML Purifier is not compatible with zend.ze1_compatibility_mode; please turn it off", E_USER_ERROR);
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
||||
|
||||
@@ -84,7 +84,9 @@ class MSSQLConnection extends ConnectionCommon implements Connection
|
||||
'UID' => $user,
|
||||
'PWD' => $pw,
|
||||
'Database' => $dsninfo['database'],
|
||||
'CharacterSet' => 'UTF-8'
|
||||
'CharacterSet' => 'UTF-8',
|
||||
'Encrypt' => true,
|
||||
'TrustServerCertificate' => true
|
||||
];
|
||||
// SQLSrv is persistent always
|
||||
$conn = sqlsrv_connect($dbhost, $opt);
|
||||
|
||||
294
thirdparty/creole/drivers/mysql/MySQLConnection.php
vendored
294
thirdparty/creole/drivers/mysql/MySQLConnection.php
vendored
@@ -1,294 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id: MySQLConnection.php,v 1.18 2004/09/01 14:00:28 dlawson_mi Exp $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information please see
|
||||
* <http://creole.phpdb.org>.
|
||||
*/
|
||||
|
||||
require_once 'creole/Connection.php';
|
||||
require_once 'creole/common/ConnectionCommon.php';
|
||||
include_once 'creole/drivers/mysql/MySQLResultSet.php';
|
||||
|
||||
/**
|
||||
* MySQL implementation of Connection.
|
||||
*
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @author Stig Bakken <ssb@fast.no>
|
||||
* @author Lukas Smith
|
||||
* @version $Revision: 1.18 $
|
||||
* @package creole.drivers.mysql
|
||||
*/
|
||||
class MySQLConnection extends ConnectionCommon implements Connection {
|
||||
|
||||
/** Current database (used in mysql_select_db()). */
|
||||
private $database;
|
||||
|
||||
/**
|
||||
* Connect to a database and log in as the specified user.
|
||||
*
|
||||
* @param $dsn the data source name (see DB::parseDSN for syntax)
|
||||
* @param $flags Any conneciton flags.
|
||||
* @access public
|
||||
* @throws SQLException
|
||||
* @return void
|
||||
*/
|
||||
function connect($dsninfo, $flags = 0)
|
||||
{
|
||||
if (!extension_loaded('mysql')) {
|
||||
throw new SQLException('mysql extension not loaded');
|
||||
}
|
||||
|
||||
$this->dsn = $dsninfo;
|
||||
$this->flags = $flags;
|
||||
|
||||
$persistent = ($flags & Creole::PERSISTENT) === Creole::PERSISTENT;
|
||||
|
||||
if (isset($dsninfo['protocol']) && $dsninfo['protocol'] == 'unix') {
|
||||
$dbhost = ':' . $dsninfo['socket'];
|
||||
} else {
|
||||
$dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost';
|
||||
if (!empty($dsninfo['port'])) {
|
||||
$dbhost .= ':' . $dsninfo['port'];
|
||||
}
|
||||
}
|
||||
$user = $dsninfo['username'];
|
||||
$pw = $dsninfo['password'];
|
||||
|
||||
$encoding = !empty($dsninfo['encoding']) ? $dsninfo['encoding'] : null;
|
||||
|
||||
$connect_function = $persistent ? 'mysql_pconnect' : 'mysql_connect';
|
||||
|
||||
@ini_set('track_errors', true);
|
||||
if ($dbhost && $user && $pw) {
|
||||
$conn = @$connect_function($dbhost, $user, $pw);
|
||||
} elseif ($dbhost && $user) {
|
||||
$conn = @$connect_function($dbhost, $user);
|
||||
} elseif ($dbhost) {
|
||||
$conn = @$connect_function($dbhost);
|
||||
} else {
|
||||
$conn = false;
|
||||
}
|
||||
@ini_restore('track_errors');
|
||||
if (empty($conn)) {
|
||||
if (($err = @mysql_error()) != '') {
|
||||
throw new SQLException("connect failed", $err);
|
||||
} elseif (empty($php_errormsg)) {
|
||||
throw new SQLException("connect failed");
|
||||
} else {
|
||||
throw new SQLException("connect failed", $php_errormsg);
|
||||
}
|
||||
}
|
||||
|
||||
if ($dsninfo['database']) {
|
||||
if (!@mysql_select_db($dsninfo['database'], $conn)) {
|
||||
switch(mysql_errno($conn)) {
|
||||
case 1049:
|
||||
$exc = new SQLException("no such database", mysql_error($conn));
|
||||
break;
|
||||
case 1044:
|
||||
$exc = new SQLException("access violation", mysql_error($conn));
|
||||
break;
|
||||
default:
|
||||
$exc = new SQLException("cannot select database", mysql_error($conn));
|
||||
}
|
||||
|
||||
throw $exc;
|
||||
|
||||
}
|
||||
// fix to allow calls to different databases in the same script
|
||||
$this->database = $dsninfo['database'];
|
||||
}
|
||||
|
||||
$this->dblink = $conn;
|
||||
|
||||
if ($encoding) {
|
||||
$this->executeUpdate("SET NAMES " . $encoding);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Connection::getDatabaseInfo()
|
||||
*/
|
||||
public function getDatabaseInfo()
|
||||
{
|
||||
return new MySQLDatabaseInfo($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Connection::getIdGenerator()
|
||||
*/
|
||||
public function getIdGenerator()
|
||||
{
|
||||
return new MySQLIdGenerator($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Connection::prepareStatement()
|
||||
*/
|
||||
public function prepareStatement($sql)
|
||||
{
|
||||
return new MySQLPreparedStatement($this, $sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Connection::prepareCall()
|
||||
*/
|
||||
public function prepareCall($sql) {
|
||||
throw new SQLException('MySQL does not support stored procedures.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Connection::createStatement()
|
||||
*/
|
||||
public function createStatement()
|
||||
{
|
||||
return new MySQLStatement($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Connection::disconnect()
|
||||
*/
|
||||
function close()
|
||||
{
|
||||
$ret = mysql_close($this->dblink);
|
||||
$this->dblink = null;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Connection::applyLimit()
|
||||
*/
|
||||
public function applyLimit(&$sql, $offset, $limit)
|
||||
{
|
||||
if ( $limit > 0 ) {
|
||||
$sql .= " LIMIT " . ($offset > 0 ? $offset . ", " : "") . $limit;
|
||||
} else if ( $offset > 0 ) {
|
||||
$sql .= " LIMIT " . $offset . ", 18446744073709551615";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Connection::executeQuery()
|
||||
*/
|
||||
function executeQuery($sql, $fetchmode = null)
|
||||
{
|
||||
$this->lastQuery = $sql;
|
||||
if ($this->database) {
|
||||
if (!@mysql_select_db($this->database, $this->dblink)) {
|
||||
throw new SQLException('No database selected', mysql_error($this->dblink));
|
||||
}
|
||||
}//echo $sql . '<br /><br />';
|
||||
$result = @mysql_query($sql, $this->dblink);
|
||||
|
||||
if (!$result) {
|
||||
if (!defined('DEBUG_SQL')) {
|
||||
define('DEBUG_SQL', 0);
|
||||
}
|
||||
if (DEBUG_SQL == 1) {
|
||||
throw new SQLException('Could not execute query', mysql_error($this->dblink), $sql);
|
||||
} else {
|
||||
throw new SQLException('It is not possible to execute the query. Please contact your system administrator');
|
||||
}
|
||||
}
|
||||
return new MySQLResultSet($this, $result, $fetchmode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Connection::executeUpdate()
|
||||
*/
|
||||
function executeUpdate($sql)
|
||||
{
|
||||
$this->lastQuery = $sql;
|
||||
|
||||
if ($this->database) {
|
||||
if (!@mysql_select_db($this->database, $this->dblink)) {
|
||||
throw new SQLException('No database selected', mysql_error($this->dblink));
|
||||
}
|
||||
}
|
||||
|
||||
$result = @mysql_query($sql, $this->dblink);
|
||||
if (!$result) {
|
||||
throw new SQLException('Could not execute update', mysql_error($this->dblink), $sql);
|
||||
}
|
||||
return (int) mysql_affected_rows($this->dblink);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a database transaction.
|
||||
* @throws SQLException
|
||||
* @return void
|
||||
*/
|
||||
protected function beginTrans()
|
||||
{
|
||||
$result = @mysql_query('SET AUTOCOMMIT=0', $this->dblink);
|
||||
$result = @mysql_query('BEGIN', $this->dblink);
|
||||
if (!$result) {
|
||||
throw new SQLException('Could not begin transaction', mysql_error($this->dblink));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit the current transaction.
|
||||
* @throws SQLException
|
||||
* @return void
|
||||
*/
|
||||
protected function commitTrans()
|
||||
{
|
||||
if ($this->database) {
|
||||
if (!@mysql_select_db($this->database, $this->dblink)) {
|
||||
throw new SQLException('No database selected', mysql_error($this->dblink));
|
||||
}
|
||||
}
|
||||
$result = @mysql_query('COMMIT', $this->dblink);
|
||||
$result = @mysql_query('SET AUTOCOMMIT=1', $this->dblink);
|
||||
if (!$result) {
|
||||
throw new SQLException('Can not commit transaction', mysql_error($this->dblink));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll back (undo) the current transaction.
|
||||
* @throws SQLException
|
||||
* @return void
|
||||
*/
|
||||
protected function rollbackTrans()
|
||||
{
|
||||
if ($this->database) {
|
||||
if (!@mysql_select_db($this->database, $this->dblink)) {
|
||||
throw new SQLException('No database selected', mysql_error($this->dblink));
|
||||
}
|
||||
}
|
||||
$result = @mysql_query('ROLLBACK', $this->dblink);
|
||||
$result = @mysql_query('SET AUTOCOMMIT=1', $this->dblink);
|
||||
if (!$result) {
|
||||
throw new SQLException('Could not rollback transaction', mysql_error($this->dblink));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of rows affected by the data manipulation
|
||||
* query.
|
||||
*
|
||||
* @return int Number of rows affected by the last query.
|
||||
*/
|
||||
function getUpdateCount()
|
||||
{
|
||||
return (int) @mysql_affected_rows($this->dblink);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once 'creole/IdGenerator.php';
|
||||
|
||||
/**
|
||||
* MySQL IdGenerator implimenation.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @version $Revision: 1.6 $
|
||||
* @package creole.drivers.mysql
|
||||
*/
|
||||
class MySQLIdGenerator implements IdGenerator {
|
||||
|
||||
/** Connection object that instantiated this class */
|
||||
private $conn;
|
||||
|
||||
/**
|
||||
* Creates a new IdGenerator class, saves passed connection for use
|
||||
* later by getId() method.
|
||||
* @param Connection $conn
|
||||
*/
|
||||
public function __construct(Connection $conn)
|
||||
{
|
||||
$this->conn = $conn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IdGenerator::isBeforeInsert()
|
||||
*/
|
||||
public function isBeforeInsert()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IdGenerator::isAfterInsert()
|
||||
*/
|
||||
public function isAfterInsert()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IdGenerator::getIdMethod()
|
||||
*/
|
||||
public function getIdMethod()
|
||||
{
|
||||
return self::AUTOINCREMENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last-generated auto-increment ID.
|
||||
*
|
||||
* Note that for very large values (2,147,483,648 to 9,223,372,036,854,775,807) a string
|
||||
* will be returned, because these numbers are larger than supported by PHP's native
|
||||
* numeric datatypes.
|
||||
*
|
||||
* @see IdGenerator::getId()
|
||||
*/
|
||||
public function getId($unused = null)
|
||||
{
|
||||
$insert_id = mysql_insert_id($this->conn->getResource());
|
||||
if ( $insert_id < 0 ) {
|
||||
$insert_id = null;
|
||||
$result = mysql_query('SELECT LAST_INSERT_ID()', $this->conn->getResource());
|
||||
if ( $result ) {
|
||||
$row = mysql_fetch_row($result);
|
||||
$insert_id = $row ? $row[0] : null;
|
||||
}
|
||||
}
|
||||
return $insert_id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id: MySQLPreparedStatement.php,v 1.7 2005/12/10 13:46:55 hlellelid Exp $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information please see
|
||||
* <http://creole.phpdb.org>.
|
||||
*/
|
||||
|
||||
require_once 'creole/PreparedStatement.php';
|
||||
require_once 'creole/common/PreparedStatementCommon.php';
|
||||
|
||||
/**
|
||||
* MySQL subclass for prepared statements.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @version $Revision: 1.7 $
|
||||
* @package creole.drivers.mysql
|
||||
*/
|
||||
class MySQLPreparedStatement extends PreparedStatementCommon implements PreparedStatement {
|
||||
|
||||
/**
|
||||
* Quotes string using native mysql function (mysql_real_escape_string()).
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
protected function escape($str)
|
||||
{
|
||||
return mysql_real_escape_string($str, $this->conn->getResource());
|
||||
}
|
||||
|
||||
}
|
||||
165
thirdparty/creole/drivers/mysql/MySQLResultSet.php
vendored
165
thirdparty/creole/drivers/mysql/MySQLResultSet.php
vendored
@@ -1,165 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id: MySQLResultSet.php,v 1.24 2006/01/17 19:44:39 hlellelid Exp $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information please see
|
||||
* <http://creole.phpdb.org>.
|
||||
*/
|
||||
|
||||
require_once 'creole/ResultSet.php';
|
||||
require_once 'creole/common/ResultSetCommon.php';
|
||||
|
||||
/**
|
||||
* MySQL implementation of ResultSet class.
|
||||
*
|
||||
* MySQL supports OFFSET / LIMIT natively; this means that no adjustments or checking
|
||||
* are performed. We will assume that if the lmitSQL() operation failed that an
|
||||
* exception was thrown, and that OFFSET/LIMIT will never be emulated for MySQL.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @version $Revision: 1.24 $
|
||||
* @package creole.drivers.mysql
|
||||
*/
|
||||
class MySQLResultSet extends ResultSetCommon implements ResultSet {
|
||||
|
||||
/**
|
||||
* @see ResultSet::seek()
|
||||
*/
|
||||
public function seek($rownum)
|
||||
{
|
||||
// MySQL rows start w/ 0, but this works, because we are
|
||||
// looking to move the position _before_ the next desired position
|
||||
if (!@mysql_data_seek($this->result, $rownum)) {
|
||||
return false;
|
||||
}
|
||||
$this->cursorPos = $rownum;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ResultSet::next()
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
$this->fields = mysql_fetch_array($this->result, $this->fetchmode);
|
||||
|
||||
if (!$this->fields) {
|
||||
$errno = mysql_errno($this->conn->getResource());
|
||||
if (!$errno) {
|
||||
// We've advanced beyond end of recordset.
|
||||
$this->afterLast();
|
||||
return false;
|
||||
} else {
|
||||
throw new SQLException("Error fetching result", mysql_error($this->conn->getResource()));
|
||||
}
|
||||
}
|
||||
/*else {
|
||||
if (is_array($this->fields)) {
|
||||
foreach ($this->fields as $sKey => $sValue) {
|
||||
if (function_exists('mb_detect_encoding')) {
|
||||
if (strtoupper(mb_detect_encoding($sValue)) == 'UTF-8') {
|
||||
$this->fields[$sKey] = utf8_encode($sValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if ($this->fetchmode === ResultSet::FETCHMODE_ASSOC && $this->lowerAssocCase) {
|
||||
$this->fields = array_change_key_case($this->fields, CASE_LOWER);
|
||||
}
|
||||
|
||||
// Advance cursor position
|
||||
$this->cursorPos++;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ResultSet::getRecordCount()
|
||||
*/
|
||||
function getRecordCount()
|
||||
{
|
||||
$rows = @mysql_num_rows($this->result);
|
||||
if ($rows === null) {
|
||||
throw new SQLException("Error fetching num rows", mysql_error($this->conn->getResource()));
|
||||
}
|
||||
return (int) $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ResultSet::close()
|
||||
*/
|
||||
function close()
|
||||
{
|
||||
if(is_resource($this->result))
|
||||
@mysql_free_result($this->result);
|
||||
$this->fields = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get string version of column.
|
||||
* No rtrim() necessary for MySQL, as this happens natively.
|
||||
* @see ResultSet::getString()
|
||||
*/
|
||||
public function getString($column)
|
||||
{
|
||||
$idx = (is_int($column) ? $column - 1 : $column);
|
||||
if (!array_key_exists($idx, $this->fields)) { throw new SQLException("Invalid resultset column: " . $column); }
|
||||
if ($this->fields[$idx] === null) { return null; }
|
||||
return (string) $this->fields[$idx];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unix epoch timestamp based on either a TIMESTAMP or DATETIME field.
|
||||
* @param mixed $column Column name (string) or index (int) starting with 1.
|
||||
* @return string
|
||||
* @throws SQLException - If the column specified is not a valid key in current field array.
|
||||
*/
|
||||
function getTimestamp($column, $format='Y-m-d H:i:s')
|
||||
{
|
||||
if (is_int($column)) { $column--; } // because Java convention is to start at 1
|
||||
if (!array_key_exists($column, $this->fields)) { throw new SQLException("Invalid resultset column: " . (is_int($column) ? $column + 1 : $column)); }
|
||||
if ($this->fields[$column] === null) { return null; }
|
||||
|
||||
if (($this->fields[$column] == '0000-00-00 00:00:00') || ($this->fields[$column] == '0000-00-00')) {
|
||||
$ts = '943916400';
|
||||
}
|
||||
else {
|
||||
$ts = strtotime($this->fields[$column]);
|
||||
}
|
||||
if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
|
||||
// otherwise it's an ugly MySQL timestamp!
|
||||
// YYYYMMDDHHMMSS
|
||||
if (preg_match('/([\d]{4})([\d]{2})([\d]{2})([\d]{2})([\d]{2})([\d]{2})/', $this->fields[$column], $matches)) {
|
||||
// YYYY MM DD HH MM SS
|
||||
// $1 $2 $3 $4 $5 $6
|
||||
$ts = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
|
||||
}
|
||||
}
|
||||
if ($ts === -1 || $ts === false) { // if it's still -1, then there's nothing to be done; use a different method.
|
||||
throw new SQLException("Unable to convert value at column " . (is_int($column) ? $column + 1 : $column) . " to timestamp: " . $this->fields[$column]);
|
||||
}
|
||||
if ($format === null) {
|
||||
return $ts;
|
||||
}
|
||||
if (strpos($format, '%') !== false) {
|
||||
return strftime($format, $ts);
|
||||
} else {
|
||||
return date($format, $ts);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id: MySQLStatement.php,v 1.1 2004/02/19 02:49:42 hlellelid Exp $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information please see
|
||||
* <http://creole.phpdb.org>.
|
||||
*/
|
||||
|
||||
require_once 'creole/Statement.php';
|
||||
require_once 'creole/common/StatementCommon.php';
|
||||
|
||||
/**
|
||||
* MySQL Statement
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @author Stig Bakken <ssb@fast.no>
|
||||
* @author Lukas Smith
|
||||
* @version $Revision: 1.1 $
|
||||
* @package creole.drivers.mysql
|
||||
*/
|
||||
class MySQLStatement extends StatementCommon implements Statement {
|
||||
|
||||
}
|
||||
102
thirdparty/creole/drivers/mysql/MySQLTypes.php
vendored
102
thirdparty/creole/drivers/mysql/MySQLTypes.php
vendored
@@ -1,102 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* $Id: MySQLTypes.php,v 1.8 2005/02/10 09:22:40 pachanga Exp $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information please see
|
||||
* <http://creole.phpdb.org>.
|
||||
*/
|
||||
|
||||
require_once 'creole/CreoleTypes.php';
|
||||
|
||||
/**
|
||||
* MySQL types / type map.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @version $Revision: 1.8 $
|
||||
* @package creole.drivers.mysql
|
||||
*/
|
||||
class MySQLTypes extends CreoleTypes {
|
||||
|
||||
/** Map MySQL native types to Creole (JDBC) types. */
|
||||
private static $typeMap = array(
|
||||
'tinyint' => CreoleTypes::TINYINT,
|
||||
'smallint' => CreoleTypes::SMALLINT,
|
||||
'mediumint' => CreoleTypes::SMALLINT,
|
||||
'int' => CreoleTypes::INTEGER,
|
||||
'integer' => CreoleTypes::INTEGER,
|
||||
'bigint' => CreoleTypes::BIGINT,
|
||||
'int24' => CreoleTypes::BIGINT,
|
||||
'real' => CreoleTypes::REAL,
|
||||
'float' => CreoleTypes::FLOAT,
|
||||
'decimal' => CreoleTypes::DECIMAL,
|
||||
'numeric' => CreoleTypes::NUMERIC,
|
||||
'double' => CreoleTypes::DOUBLE,
|
||||
'char' => CreoleTypes::CHAR,
|
||||
'varchar' => CreoleTypes::VARCHAR,
|
||||
'date' => CreoleTypes::DATE,
|
||||
'time' => CreoleTypes::TIME,
|
||||
'year' => CreoleTypes::YEAR,
|
||||
'datetime' => CreoleTypes::TIMESTAMP,
|
||||
'timestamp' => CreoleTypes::TIMESTAMP,
|
||||
'tinyblob' => CreoleTypes::BINARY,
|
||||
'blob' => CreoleTypes::VARBINARY,
|
||||
'mediumblob' => CreoleTypes::VARBINARY,
|
||||
'longblob' => CreoleTypes::VARBINARY,
|
||||
'longtext' => CreoleTypes::LONGVARCHAR,
|
||||
'tinytext' => CreoleTypes::VARCHAR,
|
||||
'mediumtext' => CreoleTypes::LONGVARCHAR,
|
||||
'text' => CreoleTypes::LONGVARCHAR,
|
||||
'enum' => CreoleTypes::CHAR,
|
||||
'set' => CreoleTypes::CHAR,
|
||||
);
|
||||
|
||||
/** Reverse mapping, created on demand. */
|
||||
private static $reverseMap = null;
|
||||
|
||||
/**
|
||||
* This method returns the generic Creole (JDBC-like) type
|
||||
* when given the native db type.
|
||||
* @param string $nativeType DB native type (e.g. 'TEXT', 'byetea', etc.).
|
||||
* @return int Creole native type (e.g. CreoleTypes::LONGVARCHAR, CreoleTypes::BINARY, etc.).
|
||||
*/
|
||||
public static function getType($nativeType)
|
||||
{
|
||||
$t = strtolower($nativeType);
|
||||
if (isset(self::$typeMap[$t])) {
|
||||
return self::$typeMap[$t];
|
||||
} else {
|
||||
return CreoleTypes::OTHER;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return a native type that corresponds to the specified
|
||||
* Creole (JDBC-like) type.
|
||||
* If there is more than one matching native type, then the LAST defined
|
||||
* native type will be returned.
|
||||
* @param int $creoleType
|
||||
* @return string Native type string.
|
||||
*/
|
||||
public static function getNativeType($creoleType)
|
||||
{
|
||||
if (self::$reverseMap === null) {
|
||||
self::$reverseMap = array_flip(self::$typeMap);
|
||||
}
|
||||
return @self::$reverseMap[$creoleType];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id: MySQLDatabaseInfo.php,v 1.13 2006/01/17 19:44:39 hlellelid Exp $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information please see
|
||||
* <http://creole.phpdb.org>.
|
||||
*/
|
||||
|
||||
require_once 'creole/metadata/DatabaseInfo.php';
|
||||
|
||||
/**
|
||||
* MySQL implementation of DatabaseInfo.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @version $Revision: 1.13 $
|
||||
* @package creole.drivers.mysql.metadata
|
||||
*/
|
||||
class MySQLDatabaseInfo extends DatabaseInfo {
|
||||
|
||||
/**
|
||||
* @throws SQLException
|
||||
* @return void
|
||||
*/
|
||||
protected function initTables()
|
||||
{
|
||||
include_once 'creole/drivers/mysql/metadata/MySQLTableInfo.php';
|
||||
// using $this->dblink was causing tests to break
|
||||
// perhaps dblink is changed by another test ... ?
|
||||
$result = @mysql_query("SHOW TABLES FROM `" . $this->dbname . "`", $this->conn->getResource());
|
||||
|
||||
if (!$result) {
|
||||
throw new SQLException("Could not list tables", mysql_error($this->conn->getResource()));
|
||||
}
|
||||
|
||||
while ($row = mysql_fetch_row($result)) {
|
||||
$this->tables[strtoupper($row[0])] = new MySQLTableInfo($this, $row[0]);
|
||||
}
|
||||
|
||||
$this->tablesLoaded = true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* MySQL does not support sequences.
|
||||
*
|
||||
* @return void
|
||||
* @throws SQLException
|
||||
*/
|
||||
protected function initSequences()
|
||||
{
|
||||
// throw new SQLException("MySQL does not support sequences natively.");
|
||||
}
|
||||
}
|
||||
@@ -1,252 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id: MySQLTableInfo.php,v 1.20 2006/01/17 19:44:39 hlellelid Exp $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information please see
|
||||
* <http://creole.phpdb.org>.
|
||||
*/
|
||||
|
||||
require_once 'creole/metadata/TableInfo.php';
|
||||
|
||||
/**
|
||||
* MySQL implementation of TableInfo.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @version $Revision: 1.20 $
|
||||
* @package creole.drivers.mysql.metadata
|
||||
*/
|
||||
class MySQLTableInfo extends TableInfo {
|
||||
|
||||
/** Loads the columns for this table. */
|
||||
protected function initColumns()
|
||||
{
|
||||
include_once 'creole/metadata/ColumnInfo.php';
|
||||
include_once 'creole/drivers/mysql/MySQLTypes.php';
|
||||
|
||||
if (!@mysql_select_db($this->dbname, $this->conn->getResource())) {
|
||||
throw new SQLException('No database selected');
|
||||
}
|
||||
|
||||
// To get all of the attributes we need, we use
|
||||
// the MySQL "SHOW COLUMNS FROM $tablename" SQL. We cannot
|
||||
// use the API functions (e.g. mysql_list_fields() because they
|
||||
// do not return complete information -- e.g. precision / scale, default
|
||||
// values).
|
||||
|
||||
$res = mysql_query("SHOW COLUMNS FROM `" . $this->name . "`", $this->conn->getResource());
|
||||
|
||||
$defaults = array();
|
||||
$nativeTypes = array();
|
||||
$precisions = array();
|
||||
|
||||
while($row = mysql_fetch_assoc($res)) {
|
||||
$name = $row['Field'];
|
||||
$is_nullable = ($row['Null'] == 'YES');
|
||||
$is_auto_increment = (strpos($row['Extra'], 'auto_increment') !== false);
|
||||
$size = null;
|
||||
$precision = null;
|
||||
$scale = null;
|
||||
|
||||
if (preg_match('/^(\w+)[\(]?([\d,]*)[\)]?( |$)/', $row['Type'], $matches)) {
|
||||
// colname[1] size/precision[2]
|
||||
$nativeType = $matches[1];
|
||||
if ($matches[2]) {
|
||||
if ( ($cpos = strpos($matches[2], ',')) !== false) {
|
||||
$size = (int) substr($matches[2], 0, $cpos);
|
||||
$precision = $size;
|
||||
$scale = (int) substr($matches[2], $cpos + 1);
|
||||
} else {
|
||||
$size = (int) $matches[2];
|
||||
}
|
||||
}
|
||||
} elseif (preg_match('/^(\w+)\(/', $row['Type'], $matches)) {
|
||||
$nativeType = $matches[1];
|
||||
} else {
|
||||
$nativeType = $row['Type'];
|
||||
}
|
||||
//BLOBs can't have any default values in MySQL
|
||||
$default = preg_match('~blob|text~', $nativeType) ? null : $row['Default'];
|
||||
$this->columns[$name] = new ColumnInfo($this,
|
||||
$name,
|
||||
MySQLTypes::getType($nativeType),
|
||||
$nativeType,
|
||||
$size,
|
||||
$precision,
|
||||
$scale,
|
||||
$is_nullable,
|
||||
$default,
|
||||
$is_auto_increment,
|
||||
$row);
|
||||
}
|
||||
|
||||
$this->colsLoaded = true;
|
||||
}
|
||||
|
||||
/** Loads the primary key information for this table. */
|
||||
protected function initPrimaryKey()
|
||||
{
|
||||
include_once 'creole/metadata/PrimaryKeyInfo.php';
|
||||
|
||||
// columns have to be loaded first
|
||||
if (!$this->colsLoaded) $this->initColumns();
|
||||
|
||||
if (!@mysql_select_db($this->dbname, $this->conn->getResource())) {
|
||||
throw new SQLException('No database selected');
|
||||
}
|
||||
|
||||
// Primary Keys
|
||||
$res = mysql_query("SHOW KEYS FROM `" . $this->name . "`", $this->conn->getResource());
|
||||
|
||||
// Loop through the returned results, grouping the same key_name together
|
||||
// adding each column for that key.
|
||||
|
||||
while($row = mysql_fetch_assoc($res)) {
|
||||
// Skip any non-primary keys.
|
||||
if ($row['Key_name'] !== 'PRIMARY') {
|
||||
continue;
|
||||
}
|
||||
$name = $row["Column_name"];
|
||||
if (!isset($this->primaryKey)) {
|
||||
$this->primaryKey = new PrimaryKeyInfo($name, $row);
|
||||
}
|
||||
$this->primaryKey->addColumn($this->columns[$name]);
|
||||
}
|
||||
|
||||
$this->pkLoaded = true;
|
||||
}
|
||||
|
||||
/** Loads the indexes for this table. */
|
||||
protected function initIndexes() {
|
||||
|
||||
include_once 'creole/metadata/IndexInfo.php';
|
||||
|
||||
// columns have to be loaded first
|
||||
if (!$this->colsLoaded) $this->initColumns();
|
||||
|
||||
if (!@mysql_select_db($this->dbname, $this->conn->getResource())) {
|
||||
throw new SQLException('No database selected');
|
||||
}
|
||||
|
||||
// Indexes
|
||||
$res = mysql_query("SHOW INDEX FROM `" . $this->name . "`", $this->conn->getResource());
|
||||
|
||||
// Loop through the returned results, grouping the same key_name together
|
||||
// adding each column for that key.
|
||||
|
||||
while($row = mysql_fetch_assoc($res)) {
|
||||
$colName = $row["Column_name"];
|
||||
$name = $row["Key_name"];
|
||||
|
||||
if($name == "PRIMARY") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($this->indexes[$name])) {
|
||||
$isUnique = ($row["Non_unique"] == 0);
|
||||
$this->indexes[$name] = new IndexInfo($name, $isUnique, $row);
|
||||
}
|
||||
$this->indexes[$name]->addColumn($this->columns[$colName]);
|
||||
}
|
||||
|
||||
$this->indexesLoaded = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load foreign keys for supporting versions of MySQL.
|
||||
* @author Tony Bibbs
|
||||
*/
|
||||
protected function initForeignKeys() {
|
||||
|
||||
// First make sure we have supported version of MySQL:
|
||||
$res = mysql_query("SELECT VERSION()");
|
||||
$row = mysql_fetch_row($res);
|
||||
|
||||
// Yes, it is OK to hardcode this...this was the first version of MySQL
|
||||
// that supported foreign keys
|
||||
if ($row[0] < '3.23.44') {
|
||||
$this->fksLoaded = true;
|
||||
return;
|
||||
}
|
||||
|
||||
include_once 'creole/metadata/ForeignKeyInfo.php';
|
||||
|
||||
// columns have to be loaded first
|
||||
if (!$this->colsLoaded) $this->initColumns();
|
||||
if (!@mysql_select_db($this->dbname, $this->conn->getResource())) {
|
||||
throw new SQLException('No database selected');
|
||||
}
|
||||
// Get the CREATE TABLE syntax
|
||||
$res = mysql_query("SHOW CREATE TABLE `" . $this->name . "`", $this->conn->getResource());
|
||||
$row = mysql_fetch_row($res);
|
||||
|
||||
// Get the information on all the foreign keys
|
||||
$regEx = '/FOREIGN KEY \(`([^`]*)`\) REFERENCES `([^`]*)` \(`([^`]*)`\)(.*)/';
|
||||
if (preg_match_all($regEx,$row[1],$matches)) {
|
||||
$tmpArray = array_keys($matches[0]);
|
||||
foreach ($tmpArray as $curKey) {
|
||||
$name = $matches[1][$curKey];
|
||||
$ftbl = $matches[2][$curKey];
|
||||
$fcol = $matches[3][$curKey];
|
||||
$fkey = $matches[4][$curKey];
|
||||
if (!isset($this->foreignKeys[$name])) {
|
||||
$this->foreignKeys[$name] = new ForeignKeyInfo($name);
|
||||
if ($this->database->hasTable($ftbl)) {
|
||||
$foreignTable = $this->database->getTable($ftbl);
|
||||
} else {
|
||||
$foreignTable = new MySQLTableInfo($this->database, $ftbl);
|
||||
$this->database->addTable($foreignTable);
|
||||
}
|
||||
if ($foreignTable->hasColumn($fcol)) {
|
||||
$foreignCol = $foreignTable->getColumn($fcol);
|
||||
} else {
|
||||
$foreignCol = new ColumnInfo($foreignTable, $fcol);
|
||||
$foreignTable->addColumn($foreignCol);
|
||||
}
|
||||
|
||||
//typical for mysql is RESTRICT
|
||||
$fkactions = array(
|
||||
'ON DELETE' => ForeignKeyInfo::RESTRICT,
|
||||
'ON UPDATE' => ForeignKeyInfo::RESTRICT,
|
||||
);
|
||||
|
||||
if ($fkey) {
|
||||
//split foreign key information -> search for ON DELETE and afterwords for ON UPDATE action
|
||||
foreach (array_keys($fkactions) as $fkaction) {
|
||||
$result = NULL;
|
||||
preg_match('/' . $fkaction . ' (' . ForeignKeyInfo::CASCADE . '|' . ForeignKeyInfo::SETNULL . ')/', $fkey, $result);
|
||||
if ($result && is_array($result) && isset($result[1])) {
|
||||
$fkactions[$fkaction] = $result[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->foreignKeys[$name]->addReference($this->columns[$name], $foreignCol, $fkactions['ON DELETE'], $fkactions['ON UPDATE']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->fksLoaded = true;
|
||||
|
||||
}
|
||||
|
||||
protected function initVendorSpecificInfo()
|
||||
{
|
||||
$res = mysql_query("SHOW TABLE STATUS LIKE '" . $this->name . "'", $this->conn->getResource());
|
||||
$this->vendorSpecificInfo = mysql_fetch_assoc($res);
|
||||
|
||||
$this->vendorLoaded = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -75,11 +75,9 @@ class MySQLiConnection extends ConnectionCommon implements Connection {
|
||||
|
||||
$encoding = !empty($dsninfo['encoding']) ? $dsninfo['encoding'] : null;
|
||||
|
||||
@ini_set('track_errors', true);
|
||||
|
||||
$conn = mysqli_connect($host, $user, $pw, $database, $port, $socket);
|
||||
|
||||
@ini_restore('track_errors');
|
||||
$conn = mysqli_connect($host, $user, $pw, $database, $port, $socket);
|
||||
$errorGetLast = error_get_last();
|
||||
$php_errormsg = isset($errorGetLast['message']) ? $errorGetLast['message'] : '';
|
||||
|
||||
if (empty($conn)) {
|
||||
if (($err = @mysqli_error()) != '') {
|
||||
|
||||
1
thirdparty/pear/DB.php
vendored
1
thirdparty/pear/DB.php
vendored
@@ -708,7 +708,6 @@ class DB
|
||||
if (!extension_loaded($name)) {
|
||||
$dlext = OS_WINDOWS ? '.dll' : '.so';
|
||||
$dlprefix = OS_WINDOWS ? 'php_' : '';
|
||||
@dl($dlprefix . $name . $dlext);
|
||||
return extension_loaded($name);
|
||||
}
|
||||
return true;
|
||||
|
||||
81
thirdparty/pear/DB/oci8.php
vendored
81
thirdparty/pear/DB/oci8.php
vendored
@@ -20,11 +20,6 @@
|
||||
// $Id: oci8.php 3355 2005-06-11 22:14:40Z nbm $
|
||||
|
||||
|
||||
// be aware... OCIError() only appears to return anything when given a
|
||||
// statement, so functions return the generic DB_ERROR instead of more
|
||||
// useful errors that have to do with feedback from the database.
|
||||
|
||||
|
||||
require_once 'DB/common.php';
|
||||
|
||||
/**
|
||||
@@ -127,7 +122,7 @@ class DB_oci8 extends DB_common
|
||||
$conn = false;
|
||||
}
|
||||
if ($conn == false) {
|
||||
$error = OCIError();
|
||||
$error = oci_error();
|
||||
$error = (is_array($error)) ? $error['message'] : null;
|
||||
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null,
|
||||
null, $error);
|
||||
@@ -146,7 +141,7 @@ class DB_oci8 extends DB_common
|
||||
*/
|
||||
function disconnect()
|
||||
{
|
||||
$ret = @OCILogOff($this->connection);
|
||||
$ret = @oci_close($this->connection);
|
||||
$this->connection = null;
|
||||
return $ret;
|
||||
}
|
||||
@@ -169,14 +164,14 @@ class DB_oci8 extends DB_common
|
||||
$this->_data = array();
|
||||
$this->last_query = $query;
|
||||
$query = $this->modifyQuery($query);
|
||||
$result = @OCIParse($this->connection, $query);
|
||||
$result = @oci_parse($this->connection, $query);
|
||||
if (!$result) {
|
||||
return $this->oci8RaiseError();
|
||||
}
|
||||
if ($this->autoCommit) {
|
||||
$success = @OCIExecute($result,OCI_COMMIT_ON_SUCCESS);
|
||||
$success = @oci_execute($result,OCI_COMMIT_ON_SUCCESS);
|
||||
} else {
|
||||
$success = @OCIExecute($result,OCI_DEFAULT);
|
||||
$success = @oci_execute($result,OCI_DEFAULT);
|
||||
}
|
||||
if (!$success) {
|
||||
return $this->oci8RaiseError($result);
|
||||
@@ -231,14 +226,14 @@ class DB_oci8 extends DB_common
|
||||
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
|
||||
}
|
||||
if ($fetchmode & DB_FETCHMODE_ASSOC) {
|
||||
$moredata = @OCIFetchInto($result,$arr,OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS);
|
||||
$moredata = @oci_fetch_all($result,$arr,OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS);
|
||||
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE &&
|
||||
$moredata)
|
||||
{
|
||||
$arr = array_change_key_case($arr, CASE_LOWER);
|
||||
}
|
||||
} else {
|
||||
$moredata = OCIFetchInto($result,$arr,OCI_RETURN_NULLS+OCI_RETURN_LOBS);
|
||||
$moredata = oci_fetch_all($result,$arr,OCI_RETURN_NULLS+OCI_RETURN_LOBS);
|
||||
}
|
||||
if (!$moredata) {
|
||||
return null;
|
||||
@@ -264,7 +259,7 @@ class DB_oci8 extends DB_common
|
||||
*/
|
||||
function freeResult($result)
|
||||
{
|
||||
return @OCIFreeStatement($result);
|
||||
return @oci_free_statement($result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,7 +324,7 @@ class DB_oci8 extends DB_common
|
||||
*/
|
||||
function numCols($result)
|
||||
{
|
||||
$cols = @OCINumCols($result);
|
||||
$cols = @oci_num_fields($result);
|
||||
if (!$cols) {
|
||||
return $this->oci8RaiseError($result);
|
||||
}
|
||||
@@ -341,8 +336,8 @@ class DB_oci8 extends DB_common
|
||||
|
||||
/**
|
||||
* Get the native error code of the last error (if any) that occured
|
||||
* on the current connection. This does not work, as OCIError does
|
||||
* not work unless given a statement. If OCIError does return
|
||||
* on the current connection. This does not work, as oci_error does
|
||||
* not work unless given a statement. If oci_error does return
|
||||
* something, so will this.
|
||||
*
|
||||
* @return int native oci8 error code
|
||||
@@ -350,9 +345,9 @@ class DB_oci8 extends DB_common
|
||||
function errorNative()
|
||||
{
|
||||
if (is_resource($this->last_stmt)) {
|
||||
$error = @OCIError($this->last_stmt);
|
||||
$error = @oci_error($this->last_stmt);
|
||||
} else {
|
||||
$error = @OCIError($this->connection);
|
||||
$error = @oci_error($this->connection);
|
||||
}
|
||||
if (is_array($error)) {
|
||||
return $error['code'];
|
||||
@@ -422,7 +417,7 @@ class DB_oci8 extends DB_common
|
||||
|
||||
$this->last_query = $query;
|
||||
$newquery = $this->modifyQuery($newquery);
|
||||
if (!$stmt = @OCIParse($this->connection, $newquery)) {
|
||||
if (!$stmt = @oci_parse($this->connection, $newquery)) {
|
||||
return $this->oci8RaiseError();
|
||||
}
|
||||
$this->prepare_types[(int)$stmt] = $types;
|
||||
@@ -482,16 +477,16 @@ class DB_oci8 extends DB_common
|
||||
$data[$key] = fread($fp, filesize($data[$key]));
|
||||
fclose($fp);
|
||||
}
|
||||
if (!@OCIBindByName($stmt, ':bind' . $i, $data[$key], -1)) {
|
||||
if (!@oci_bind_by_name($stmt, ':bind' . $i, $data[$key], -1)) {
|
||||
$tmp = $this->oci8RaiseError($stmt);
|
||||
return $tmp;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
if ($this->autoCommit) {
|
||||
$success = @OCIExecute($stmt, OCI_COMMIT_ON_SUCCESS);
|
||||
$success = @oci_execute($stmt, OCI_COMMIT_ON_SUCCESS);
|
||||
} else {
|
||||
$success = @OCIExecute($stmt, OCI_DEFAULT);
|
||||
$success = @oci_execute($stmt, OCI_DEFAULT);
|
||||
}
|
||||
if (!$success) {
|
||||
$tmp = $this->oci8RaiseError($stmt);
|
||||
@@ -530,7 +525,7 @@ class DB_oci8 extends DB_common
|
||||
*/
|
||||
function commit()
|
||||
{
|
||||
$result = @OCICommit($this->connection);
|
||||
$result = @oci_commit($this->connection);
|
||||
if (!$result) {
|
||||
return $this->oci8RaiseError();
|
||||
}
|
||||
@@ -547,7 +542,7 @@ class DB_oci8 extends DB_common
|
||||
*/
|
||||
function rollback()
|
||||
{
|
||||
$result = @OCIRollback($this->connection);
|
||||
$result = @oci_rollback($this->connection);
|
||||
if (!$result) {
|
||||
return $this->oci8RaiseError();
|
||||
}
|
||||
@@ -568,7 +563,7 @@ class DB_oci8 extends DB_common
|
||||
if ($this->last_stmt === false) {
|
||||
return $this->oci8RaiseError();
|
||||
}
|
||||
$result = @OCIRowCount($this->last_stmt);
|
||||
$result = @oci_num_rows($this->last_stmt);
|
||||
if ($result === false) {
|
||||
return $this->oci8RaiseError($this->last_stmt);
|
||||
}
|
||||
@@ -613,20 +608,20 @@ class DB_oci8 extends DB_common
|
||||
} else {
|
||||
$q_fields = "SELECT * FROM ($query) WHERE NULL = NULL";
|
||||
|
||||
if (!$result = @OCIParse($this->connection, $q_fields)) {
|
||||
if (!$result = @oci_parse($this->connection, $q_fields)) {
|
||||
$this->last_query = $q_fields;
|
||||
return $this->oci8RaiseError();
|
||||
}
|
||||
if (!@OCIExecute($result, OCI_DEFAULT)) {
|
||||
if (!@oci_execute($result, OCI_DEFAULT)) {
|
||||
$this->last_query = $q_fields;
|
||||
return $this->oci8RaiseError($result);
|
||||
}
|
||||
}
|
||||
|
||||
$ncols = OCINumCols($result);
|
||||
$ncols = oci_num_fields($result);
|
||||
$cols = array();
|
||||
for ( $i = 1; $i <= $ncols; $i++ ) {
|
||||
$cols[] = '"' . OCIColumnName($result, $i) . '"';
|
||||
$cols[] = '"' . oci_field_name($result, $i) . '"';
|
||||
}
|
||||
$fields = implode(', ', $cols);
|
||||
// XXX Test that (tip by John Lim)
|
||||
@@ -743,11 +738,11 @@ class DB_oci8 extends DB_common
|
||||
function oci8RaiseError($errno = null)
|
||||
{
|
||||
if ($errno === null) {
|
||||
$error = @OCIError($this->connection);
|
||||
$error = @oci_error($this->connection);
|
||||
return $this->raiseError($this->errorCode($error['code']),
|
||||
null, null, null, $error['message']);
|
||||
} elseif (is_resource($errno)) {
|
||||
$error = @OCIError($errno);
|
||||
$error = @oci_error($errno);
|
||||
return $this->raiseError($this->errorCode($error['code']),
|
||||
null, null, null, $error['message']);
|
||||
}
|
||||
@@ -813,20 +808,20 @@ class DB_oci8 extends DB_common
|
||||
|
||||
$this->last_query = $q_fields;
|
||||
|
||||
if (!$stmt = @OCIParse($this->connection, $q_fields)) {
|
||||
if (!$stmt = @oci_parse($this->connection, $q_fields)) {
|
||||
return $this->oci8RaiseError(DB_ERROR_NEED_MORE_DATA);
|
||||
}
|
||||
if (!@OCIExecute($stmt, OCI_DEFAULT)) {
|
||||
if (!@oci_execute($stmt, OCI_DEFAULT)) {
|
||||
return $this->oci8RaiseError($stmt);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while (@OCIFetch($stmt)) {
|
||||
while (@oci_fetch($stmt)) {
|
||||
$res[$i]['table'] = $case_func($result);
|
||||
$res[$i]['name'] = $case_func(@OCIResult($stmt, 1));
|
||||
$res[$i]['type'] = @OCIResult($stmt, 2);
|
||||
$res[$i]['len'] = @OCIResult($stmt, 3);
|
||||
$res[$i]['flags'] = (@OCIResult($stmt, 4) == 'N') ? 'not_null' : '';
|
||||
$res[$i]['name'] = $case_func(@oci_result($stmt, 1));
|
||||
$res[$i]['type'] = @oci_result($stmt, 2);
|
||||
$res[$i]['len'] = @oci_result($stmt, 3);
|
||||
$res[$i]['flags'] = (@oci_result($stmt, 4) == 'N') ? 'not_null' : '';
|
||||
|
||||
if ($mode & DB_TABLEINFO_ORDER) {
|
||||
$res['order'][$res[$i]['name']] = $i;
|
||||
@@ -840,7 +835,7 @@ class DB_oci8 extends DB_common
|
||||
if ($mode) {
|
||||
$res['num_fields'] = $i;
|
||||
}
|
||||
@OCIFreeStatement($stmt);
|
||||
@oci_free_statement($stmt);
|
||||
|
||||
} else {
|
||||
if (isset($result->result)) {
|
||||
@@ -857,13 +852,13 @@ class DB_oci8 extends DB_common
|
||||
}
|
||||
|
||||
if ($result === $this->last_stmt) {
|
||||
$count = @OCINumCols($result);
|
||||
$count = @oci_num_fields($result);
|
||||
|
||||
for ($i=0; $i<$count; $i++) {
|
||||
$res[$i]['table'] = '';
|
||||
$res[$i]['name'] = $case_func(@OCIColumnName($result, $i+1));
|
||||
$res[$i]['type'] = @OCIColumnType($result, $i+1);
|
||||
$res[$i]['len'] = @OCIColumnSize($result, $i+1);
|
||||
$res[$i]['name'] = $case_func(@oci_field_name($result, $i+1));
|
||||
$res[$i]['type'] = @oci_field_type($result, $i+1);
|
||||
$res[$i]['len'] = @oci_field_size($result, $i+1);
|
||||
$res[$i]['flags'] = '';
|
||||
|
||||
if ($mode & DB_TABLEINFO_ORDER) {
|
||||
|
||||
8
thirdparty/pear/DB/pgsql.php
vendored
8
thirdparty/pear/DB/pgsql.php
vendored
@@ -123,12 +123,8 @@ class DB_pgsql extends DB_common
|
||||
|
||||
$connect_function = $persistent ? 'pg_pconnect' : 'pg_connect';
|
||||
|
||||
$ini = ini_get('track_errors');
|
||||
if ($ini) {
|
||||
$conn = @$connect_function($connstr);
|
||||
} else {
|
||||
$conn = @$connect_function($connstr);
|
||||
}
|
||||
$conn = @$connect_function($connstr);
|
||||
|
||||
if ($conn == false) {
|
||||
$lastError = error_get_last();
|
||||
$errorMessage = $lastError['message'] ?? 'Connection error.';
|
||||
|
||||
6
thirdparty/pear/Log.php
vendored
6
thirdparty/pear/Log.php
vendored
@@ -100,6 +100,12 @@ class Log
|
||||
'%{function}' => '%7$s',
|
||||
'%\{' => '%%{');
|
||||
|
||||
/**
|
||||
* Constructor of the class.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to return a concrete Log instance of type $handler.
|
||||
|
||||
6
thirdparty/pear/PEAR/Command/Remote.php
vendored
6
thirdparty/pear/PEAR/Command/Remote.php
vendored
@@ -108,9 +108,9 @@ parameter.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Remote(&$ui, &$config)
|
||||
function __construct(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
parent::__construct($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
@@ -281,7 +281,7 @@ parameter.
|
||||
return PEAR::raiseError("download expects one argument: the package to download");
|
||||
}
|
||||
$server = $this->config->get('master_server');
|
||||
if (!ereg('^http://', $params[0])) {
|
||||
if (!preg_match('/^http:\/\//', $params[0])) {
|
||||
$pkgfile = "http://$server/get/$params[0]";
|
||||
} else {
|
||||
$pkgfile = $params[0];
|
||||
|
||||
4
thirdparty/pear/PEAR/Remote.php
vendored
4
thirdparty/pear/PEAR/Remote.php
vendored
@@ -191,7 +191,7 @@ class PEAR_Remote extends PEAR
|
||||
if ($is_continuous) {
|
||||
reset($php_val);
|
||||
$arr = array();
|
||||
while (list($k, $v) = each($php_val)) {
|
||||
foreach ($php_val as $k => $v) {
|
||||
$arr[$k] = $this->_encode($v);
|
||||
}
|
||||
$xmlrpcval->addArray($arr);
|
||||
@@ -201,7 +201,7 @@ class PEAR_Remote extends PEAR
|
||||
// fall though if not numerical and continuous
|
||||
case "object":
|
||||
$arr = array();
|
||||
while (list($k, $v) = each($php_val)) {
|
||||
foreach ($php_val as $k => $v) {
|
||||
$arr[$k] = $this->_encode($v);
|
||||
}
|
||||
$xmlrpcval->addStruct($arr);
|
||||
|
||||
Reference in New Issue
Block a user