mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-08-17 20:11:23 +02:00
fixes for PHP 5.4 warnings and strict warnings, thought disabled E_STRICT for now, because of various strict warnings in working code, which could not be easy fixed in all areas (see comment in phpgwapi/inc/functions.inc.php)
This commit is contained in:
@ -1,16 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
Set tabs to 8.
|
||||
|
||||
|
||||
MySQL code that does not support transactions. Use mysqlt if you need transactions.
|
||||
Requires mysql client. Works on Windows and Unix.
|
||||
|
||||
|
||||
28 Feb 2001: MetaColumns bug fix - suggested by Freek Dijkstra (phpeverywhere@macfreek.com)
|
||||
*/
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
@ -22,8 +22,8 @@ class ADODB_mysql extends ADOConnection {
|
||||
var $databaseType = 'mysql';
|
||||
var $dataProvider = 'mysql';
|
||||
var $hasInsertID = true;
|
||||
var $hasAffectedRows = true;
|
||||
var $metaTablesSQL = "SHOW TABLES";
|
||||
var $hasAffectedRows = true;
|
||||
var $metaTablesSQL = "SHOW TABLES";
|
||||
var $metaColumnsSQL = "SHOW COLUMNS FROM %s";
|
||||
var $fmtTimeStamp = "'Y-m-d H:i:s'";
|
||||
var $hasLimit = true;
|
||||
@ -38,100 +38,100 @@ class ADODB_mysql extends ADOConnection {
|
||||
var $clientFlags = 0;
|
||||
var $substr = "substring";
|
||||
var $nameQuote = '`'; /// string to use to quote identifiers and names
|
||||
|
||||
function ADODB_mysql()
|
||||
{
|
||||
|
||||
function ADODB_mysql()
|
||||
{
|
||||
if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_';
|
||||
}
|
||||
|
||||
|
||||
function ServerInfo()
|
||||
{
|
||||
$arr['description'] = ADOConnection::GetOne("select version()");
|
||||
$arr['version'] = ADOConnection::_findvers($arr['description']);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function IfNull( $field, $ifNull )
|
||||
|
||||
function IfNull( $field, $ifNull )
|
||||
{
|
||||
return " IFNULL($field, $ifNull) "; // if MySQL
|
||||
}
|
||||
|
||||
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
|
||||
{
|
||||
|
||||
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
|
||||
{
|
||||
$save = $this->metaTablesSQL;
|
||||
if ($showSchema && is_string($showSchema)) {
|
||||
$this->metaTablesSQL .= " from $showSchema";
|
||||
}
|
||||
|
||||
|
||||
if ($mask) {
|
||||
$mask = $this->qstr($mask);
|
||||
$this->metaTablesSQL .= " like $mask";
|
||||
}
|
||||
$ret =& ADOConnection::MetaTables($ttype,$showSchema);
|
||||
|
||||
|
||||
$this->metaTablesSQL = $save;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function &MetaIndexes ($table, $primary = FALSE, $owner=false)
|
||||
{
|
||||
// save old fetch mode
|
||||
global $ADODB_FETCH_MODE;
|
||||
|
||||
|
||||
$false = false;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
if ($this->fetchMode !== FALSE) {
|
||||
$savem = $this->SetFetchMode(FALSE);
|
||||
}
|
||||
|
||||
|
||||
// get index details
|
||||
$rs = $this->Execute(sprintf('SHOW INDEX FROM %s',$table));
|
||||
|
||||
|
||||
// restore fetchmode
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
}
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
|
||||
|
||||
if (!is_object($rs)) {
|
||||
return $false;
|
||||
}
|
||||
|
||||
|
||||
$indexes = array ();
|
||||
|
||||
|
||||
// parse index data into array
|
||||
while ($row = $rs->FetchRow()) {
|
||||
if ($primary == FALSE AND $row[2] == 'PRIMARY') {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (!isset($indexes[$row[2]])) {
|
||||
$indexes[$row[2]] = array(
|
||||
'unique' => ($row[1] == 0),
|
||||
'columns' => array()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$indexes[$row[2]]['columns'][$row[3] - 1] = $row[4];
|
||||
}
|
||||
|
||||
|
||||
// sort columns by order in the index
|
||||
foreach ( array_keys ($indexes) as $index )
|
||||
{
|
||||
ksort ($indexes[$index]['columns']);
|
||||
}
|
||||
|
||||
|
||||
return $indexes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if magic quotes disabled, use mysql_real_escape_string()
|
||||
function qstr($s,$magic_quotes=false)
|
||||
{
|
||||
if (!$magic_quotes) {
|
||||
|
||||
|
||||
if (ADODB_PHPVER >= 0x4300) {
|
||||
if (is_resource($this->_connectionID))
|
||||
return "'".mysql_real_escape_string($s,$this->_connectionID)."'";
|
||||
@ -139,20 +139,20 @@ class ADODB_mysql extends ADOConnection {
|
||||
if ($this->replaceQuote[0] == '\\'){
|
||||
$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
|
||||
}
|
||||
return "'".str_replace("'",$this->replaceQuote,$s)."'";
|
||||
return "'".str_replace("'",$this->replaceQuote,$s)."'";
|
||||
}
|
||||
|
||||
|
||||
// undo magic quotes for "
|
||||
$s = str_replace('\\"','"',$s);
|
||||
return "'$s'";
|
||||
}
|
||||
|
||||
|
||||
function _insertid()
|
||||
{
|
||||
return ADOConnection::GetOne('SELECT LAST_INSERT_ID()');
|
||||
//return mysql_insert_id($this->_connectionID);
|
||||
}
|
||||
|
||||
|
||||
function GetOne($sql,$inputarr=false)
|
||||
{
|
||||
if (strncasecmp($sql,'sele',4) == 0) {
|
||||
@ -167,40 +167,40 @@ class ADODB_mysql extends ADOConnection {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function BeginTrans()
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("Transactions not supported in 'mysql' driver. Use 'mysqlt' or 'mysqli' driver");
|
||||
}
|
||||
|
||||
|
||||
function _affectedrows()
|
||||
{
|
||||
return mysql_affected_rows($this->_connectionID);
|
||||
}
|
||||
|
||||
|
||||
// See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
|
||||
// Reference on Last_Insert_ID on the recommended way to simulate sequences
|
||||
var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
|
||||
var $_genSeqSQL = "create table %s (id int not null)";
|
||||
var $_genSeq2SQL = "insert into %s values (%s)";
|
||||
var $_dropSeqSQL = "drop table %s";
|
||||
|
||||
|
||||
function CreateSequence($seqname='adodbseq',$startID=1)
|
||||
{
|
||||
if (empty($this->_genSeqSQL)) return false;
|
||||
$u = strtoupper($seqname);
|
||||
|
||||
|
||||
$ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
|
||||
if (!$ok) return false;
|
||||
return $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
function GenID($seqname='adodbseq',$startID=1)
|
||||
{
|
||||
// post-nuke sets hasGenID to false
|
||||
if (!$this->hasGenID) return false;
|
||||
|
||||
|
||||
$savelog = $this->_logsql;
|
||||
$this->_logsql = false;
|
||||
$getnext = sprintf($this->_genIDSQL,$seqname);
|
||||
@ -214,13 +214,13 @@ class ADODB_mysql extends ADOConnection {
|
||||
$rs = $this->Execute($getnext);
|
||||
}
|
||||
$this->genID = mysql_insert_id($this->_connectionID);
|
||||
|
||||
|
||||
if ($rs) $rs->Close();
|
||||
|
||||
|
||||
$this->_logsql = $savelog;
|
||||
return $this->genID;
|
||||
}
|
||||
|
||||
|
||||
function &MetaDatabases()
|
||||
{
|
||||
$qid = mysql_list_dbs($this->_connectionID);
|
||||
@ -234,11 +234,11 @@ class ADODB_mysql extends ADOConnection {
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Format date column in sql string given an input format that understands Y M D
|
||||
function SQLDate($fmt, $col=false)
|
||||
{
|
||||
{
|
||||
if (!$col) $col = $this->sysTimeStamp;
|
||||
$s = 'DATE_FORMAT('.$col.",'";
|
||||
$concat = false;
|
||||
@ -246,7 +246,7 @@ class ADODB_mysql extends ADOConnection {
|
||||
for ($i=0; $i < $len; $i++) {
|
||||
$ch = $fmt[$i];
|
||||
switch($ch) {
|
||||
|
||||
|
||||
default:
|
||||
if ($ch == '\\') {
|
||||
$i++;
|
||||
@ -257,7 +257,7 @@ class ADODB_mysql extends ADOConnection {
|
||||
case '/':
|
||||
$s .= $ch;
|
||||
break;
|
||||
|
||||
|
||||
case 'Y':
|
||||
case 'y':
|
||||
$s .= '%Y';
|
||||
@ -265,7 +265,7 @@ class ADODB_mysql extends ADOConnection {
|
||||
case 'M':
|
||||
$s .= '%b';
|
||||
break;
|
||||
|
||||
|
||||
case 'm':
|
||||
$s .= '%m';
|
||||
break;
|
||||
@ -273,41 +273,41 @@ class ADODB_mysql extends ADOConnection {
|
||||
case 'd':
|
||||
$s .= '%d';
|
||||
break;
|
||||
|
||||
|
||||
case 'Q':
|
||||
case 'q':
|
||||
$s .= "'),Quarter($col)";
|
||||
|
||||
|
||||
if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";
|
||||
else $s .= ",('";
|
||||
$concat = true;
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
|
||||
case 'H':
|
||||
$s .= '%H';
|
||||
break;
|
||||
|
||||
|
||||
case 'h':
|
||||
$s .= '%I';
|
||||
break;
|
||||
|
||||
|
||||
case 'i':
|
||||
$s .= '%i';
|
||||
break;
|
||||
|
||||
|
||||
case 's':
|
||||
$s .= '%s';
|
||||
break;
|
||||
|
||||
|
||||
case 'a':
|
||||
case 'A':
|
||||
$s .= '%p';
|
||||
break;
|
||||
|
||||
|
||||
case 'w':
|
||||
$s .= '%w';
|
||||
break;
|
||||
|
||||
|
||||
case 'l':
|
||||
$s .= '%W';
|
||||
break;
|
||||
@ -317,7 +317,7 @@ class ADODB_mysql extends ADOConnection {
|
||||
if ($concat) $s = "CONCAT($s)";
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// returns concatenated string
|
||||
// much easier to run "mysqld --ansi" or "mysqld --sql-mode=PIPES_AS_CONCAT" and use || operator
|
||||
@ -325,24 +325,24 @@ class ADODB_mysql extends ADOConnection {
|
||||
{
|
||||
$s = "";
|
||||
$arr = func_get_args();
|
||||
|
||||
|
||||
// suggestion by andrew005@mnogo.ru
|
||||
$s = implode(',',$arr);
|
||||
$s = implode(',',$arr);
|
||||
if (strlen($s) > 0) return "CONCAT($s)";
|
||||
else return '';
|
||||
}
|
||||
|
||||
|
||||
function OffsetDate($dayFraction,$date=false)
|
||||
{
|
||||
{
|
||||
if (!$date) $date = $this->sysDate;
|
||||
return "from_unixtime(unix_timestamp($date)+($dayFraction)*24*3600)";
|
||||
}
|
||||
|
||||
|
||||
// returns true or false
|
||||
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
||||
{
|
||||
if (!empty($this->port)) $argHostname .= ":".$this->port;
|
||||
|
||||
|
||||
if (ADODB_PHPVER >= 0x4300)
|
||||
$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword,
|
||||
$this->forceNewConnect,$this->clientFlags);
|
||||
@ -351,17 +351,17 @@ class ADODB_mysql extends ADOConnection {
|
||||
$this->forceNewConnect);
|
||||
else
|
||||
$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword);
|
||||
|
||||
|
||||
if ($this->_connectionID === false) return false;
|
||||
if ($argDatabasename) return $this->SelectDB($argDatabasename);
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// returns true or false
|
||||
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
||||
{
|
||||
if (!empty($this->port)) $argHostname .= ":".$this->port;
|
||||
|
||||
|
||||
if (ADODB_PHPVER >= 0x4300)
|
||||
$this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword,$this->clientFlags);
|
||||
else
|
||||
@ -369,16 +369,16 @@ class ADODB_mysql extends ADOConnection {
|
||||
if ($this->_connectionID === false) return false;
|
||||
if ($this->autoRollback) $this->RollbackTrans();
|
||||
if ($argDatabasename) return $this->SelectDB($argDatabasename);
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
||||
{
|
||||
$this->forceNewConnect = true;
|
||||
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
|
||||
}
|
||||
|
||||
function &MetaColumns($table)
|
||||
|
||||
function &MetaColumns($table,$upper=true)
|
||||
{
|
||||
$this->_findschema($table,$schema);
|
||||
if ($schema) {
|
||||
@ -388,27 +388,27 @@ class ADODB_mysql extends ADOConnection {
|
||||
global $ADODB_FETCH_MODE;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
|
||||
|
||||
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
|
||||
$rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
|
||||
|
||||
|
||||
if ($schema) {
|
||||
$this->SelectDB($dbName);
|
||||
}
|
||||
|
||||
|
||||
if (isset($savem)) $this->SetFetchMode($savem);
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
if (!is_object($rs)) {
|
||||
$false = false;
|
||||
return $false;
|
||||
}
|
||||
|
||||
|
||||
$retarr = array();
|
||||
while (!$rs->EOF){
|
||||
$fld = new ADOFieldObject();
|
||||
$fld->name = $rs->fields[0];
|
||||
$type = $rs->fields[1];
|
||||
|
||||
|
||||
// split type into type(length):
|
||||
$fld->scale = null;
|
||||
if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
|
||||
@ -433,7 +433,7 @@ class ADODB_mysql extends ADOConnection {
|
||||
$fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
|
||||
$fld->binary = (strpos($type,'blob') !== false);
|
||||
$fld->unsigned = (strpos($type,'unsigned') !== false);
|
||||
|
||||
|
||||
if (!$fld->binary) {
|
||||
$d = $rs->fields[4];
|
||||
if ($d != '' && $d != 'NULL') {
|
||||
@ -443,7 +443,7 @@ class ADODB_mysql extends ADOConnection {
|
||||
$fld->has_default = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($save == ADODB_FETCH_NUM) {
|
||||
$retarr[] = $fld;
|
||||
} else {
|
||||
@ -451,26 +451,26 @@ class ADODB_mysql extends ADOConnection {
|
||||
}
|
||||
$rs->MoveNext();
|
||||
}
|
||||
|
||||
|
||||
$rs->Close();
|
||||
return $retarr;
|
||||
return $retarr;
|
||||
}
|
||||
|
||||
|
||||
// returns true or false
|
||||
function SelectDB($dbName)
|
||||
function SelectDB($dbName)
|
||||
{
|
||||
$this->database = $dbName;
|
||||
if ($this->_connectionID) {
|
||||
return @mysql_select_db($dbName,$this->_connectionID);
|
||||
return @mysql_select_db($dbName,$this->_connectionID);
|
||||
}
|
||||
else return false;
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
// parameters use PostgreSQL convention, not MySQL
|
||||
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0)
|
||||
{
|
||||
// jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220
|
||||
if ($nrows < 0) $nrows = '18446744073709551615';
|
||||
if ($nrows < 0) $nrows = '18446744073709551615';
|
||||
|
||||
$offsetStr = (($offset>=0) ? (int)$offset.',' : '').(int)$nrows;
|
||||
|
||||
@ -491,34 +491,34 @@ class ADODB_mysql extends ADOConnection {
|
||||
$rs =& $this->Execute($sql.' LIMIT '.$offsetStr.' '.$FORUPDATE,$inputarr);
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
// returns queryID or false
|
||||
function _query($sql,$inputarr)
|
||||
{
|
||||
//global $ADODB_COUNTRECS;
|
||||
//if($ADODB_COUNTRECS)
|
||||
//if($ADODB_COUNTRECS)
|
||||
return mysql_query($sql,$this->_connectionID);
|
||||
//else return @mysql_unbuffered_query($sql,$this->_connectionID); // requires PHP >= 4.0.6
|
||||
}
|
||||
|
||||
/* Returns: the last error message from previous database operation */
|
||||
function ErrorMsg()
|
||||
/* Returns: the last error message from previous database operation */
|
||||
function ErrorMsg()
|
||||
{
|
||||
|
||||
|
||||
if ($this->_logsql) return $this->_errorMsg;
|
||||
if (empty($this->_connectionID)) $this->_errorMsg = @mysql_error();
|
||||
else $this->_errorMsg = @mysql_error($this->_connectionID);
|
||||
return $this->_errorMsg;
|
||||
}
|
||||
|
||||
/* Returns: the last error number from previous database operation */
|
||||
function ErrorNo()
|
||||
|
||||
/* Returns: the last error number from previous database operation */
|
||||
function ErrorNo()
|
||||
{
|
||||
if ($this->_logsql) return $this->_errorCode;
|
||||
if (empty($this->_connectionID)) return @mysql_errno();
|
||||
else return @mysql_errno($this->_connectionID);
|
||||
}
|
||||
|
||||
|
||||
// returns true or false
|
||||
function _close()
|
||||
{
|
||||
@ -526,23 +526,23 @@ class ADODB_mysql extends ADOConnection {
|
||||
$this->_connectionID = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Maximum size of C field
|
||||
*/
|
||||
function CharMax()
|
||||
{
|
||||
return 255;
|
||||
return 255;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Maximum size of X field
|
||||
*/
|
||||
function TextMax()
|
||||
{
|
||||
return 4294967295;
|
||||
return 4294967295;
|
||||
}
|
||||
|
||||
|
||||
// "Innox - Juan Carlos Gonzalez" <jgonzalez#innox.com.mx>
|
||||
function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $asociative = FALSE )
|
||||
{
|
||||
@ -578,7 +578,7 @@ class ADODB_mysql extends ADOConnection {
|
||||
}
|
||||
return $foreign_keys;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @var array $charset2mysql translate www charsets to mysql ones
|
||||
*/
|
||||
@ -611,7 +611,7 @@ class ADODB_mysql extends ADOConnection {
|
||||
}
|
||||
return $this->charSet ? $this->charSet : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* sets the client encoding from the connection
|
||||
*
|
||||
@ -629,20 +629,20 @@ class ADODB_mysql extends ADOConnection {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------------------
|
||||
Class Name: Recordset
|
||||
--------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
class ADORecordSet_mysql extends ADORecordSet{
|
||||
|
||||
class ADORecordSet_mysql extends ADORecordSet{
|
||||
|
||||
var $databaseType = "mysql";
|
||||
var $canSeek = true;
|
||||
|
||||
function ADORecordSet_mysql($queryID,$mode=false)
|
||||
|
||||
function ADORecordSet_mysql($queryID,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
$mode = $ADODB_FETCH_MODE;
|
||||
}
|
||||
@ -656,9 +656,9 @@ class ADORecordSet_mysql extends ADORecordSet{
|
||||
$this->fetchMode = MYSQL_BOTH; break;
|
||||
}
|
||||
$this->adodbFetchMode = $mode;
|
||||
$this->ADORecordSet($queryID);
|
||||
$this->ADORecordSet($queryID);
|
||||
}
|
||||
|
||||
|
||||
function _initrs()
|
||||
{
|
||||
//GLOBAL $ADODB_COUNTRECS;
|
||||
@ -666,9 +666,9 @@ class ADORecordSet_mysql extends ADORecordSet{
|
||||
$this->_numOfRows = @mysql_num_rows($this->_queryID);
|
||||
$this->_numOfFields = @mysql_num_fields($this->_queryID);
|
||||
}
|
||||
|
||||
function &FetchField($fieldOffset = -1)
|
||||
{
|
||||
|
||||
function &FetchField($fieldOffset = -1)
|
||||
{
|
||||
if ($fieldOffset != -1) {
|
||||
$o = @mysql_fetch_field($this->_queryID, $fieldOffset);
|
||||
$f = @mysql_field_flags($this->_queryID,$fieldOffset);
|
||||
@ -681,7 +681,7 @@ class ADORecordSet_mysql extends ADORecordSet{
|
||||
$o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich@att.com)
|
||||
//$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
|
||||
}
|
||||
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
@ -691,13 +691,13 @@ class ADORecordSet_mysql extends ADORecordSet{
|
||||
$row =& ADORecordSet::GetRowAssoc($upper);
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
/* Use associative array to get fields array */
|
||||
function Fields($colname)
|
||||
{
|
||||
{
|
||||
// added @ by "Michael William Miller" <mille562@pilot.msu.edu>
|
||||
if ($this->fetchMode != MYSQL_NUM) return @$this->fields[$colname];
|
||||
|
||||
|
||||
if (!$this->bind) {
|
||||
$this->bind = array();
|
||||
for ($i=0; $i < $this->_numOfFields; $i++) {
|
||||
@ -707,13 +707,13 @@ class ADORecordSet_mysql extends ADORecordSet{
|
||||
}
|
||||
return $this->fields[$this->bind[strtoupper($colname)]];
|
||||
}
|
||||
|
||||
|
||||
function _seek($row)
|
||||
{
|
||||
if ($this->_numOfRows == 0) return false;
|
||||
return @mysql_data_seek($this->_queryID,$row);
|
||||
}
|
||||
|
||||
|
||||
function MoveNext()
|
||||
{
|
||||
//return adodb_movenext($this);
|
||||
@ -728,18 +728,18 @@ class ADORecordSet_mysql extends ADORecordSet{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function _fetch()
|
||||
{
|
||||
$this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode);
|
||||
return is_array($this->fields);
|
||||
}
|
||||
|
||||
|
||||
function _close() {
|
||||
@mysql_free_result($this->_queryID);
|
||||
$this->_queryID = false;
|
||||
@mysql_free_result($this->_queryID);
|
||||
$this->_queryID = false;
|
||||
}
|
||||
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
{
|
||||
if (is_object($t)) {
|
||||
@ -747,58 +747,58 @@ class ADORecordSet_mysql extends ADORecordSet{
|
||||
$t = $fieldobj->type;
|
||||
$len = $fieldobj->max_length;
|
||||
}
|
||||
|
||||
|
||||
$len = -1; // mysql max_length is not accurate
|
||||
switch (strtoupper($t)) {
|
||||
case 'STRING':
|
||||
case 'STRING':
|
||||
case 'CHAR':
|
||||
case 'VARCHAR':
|
||||
case 'TINYBLOB':
|
||||
case 'TINYTEXT':
|
||||
case 'ENUM':
|
||||
case 'SET':
|
||||
case 'VARCHAR':
|
||||
case 'TINYBLOB':
|
||||
case 'TINYTEXT':
|
||||
case 'ENUM':
|
||||
case 'SET':
|
||||
if ($len <= $this->blobSize) return 'C';
|
||||
|
||||
|
||||
case 'TEXT':
|
||||
case 'LONGTEXT':
|
||||
case 'LONGTEXT':
|
||||
case 'MEDIUMTEXT':
|
||||
return 'X';
|
||||
|
||||
|
||||
// php_mysql extension always returns 'blob' even if 'text'
|
||||
// so we have to check whether binary...
|
||||
case 'IMAGE':
|
||||
case 'LONGBLOB':
|
||||
case 'LONGBLOB':
|
||||
case 'BLOB':
|
||||
case 'MEDIUMBLOB':
|
||||
return !empty($fieldobj->binary) ? 'B' : 'X';
|
||||
|
||||
|
||||
case 'YEAR':
|
||||
case 'DATE': return 'D';
|
||||
|
||||
|
||||
case 'TIME':
|
||||
case 'DATETIME':
|
||||
case 'TIMESTAMP': return 'T';
|
||||
|
||||
case 'INT':
|
||||
|
||||
case 'INT':
|
||||
case 'INTEGER':
|
||||
case 'BIGINT':
|
||||
case 'TINYINT':
|
||||
case 'MEDIUMINT':
|
||||
case 'SMALLINT':
|
||||
|
||||
case 'SMALLINT':
|
||||
|
||||
if (!empty($fieldobj->primary_key)) return 'R';
|
||||
else return 'I';
|
||||
|
||||
|
||||
default: return 'N';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ADORecordSet_ext_mysql extends ADORecordSet_mysql {
|
||||
function ADORecordSet_ext_mysql($queryID,$mode=false)
|
||||
class ADORecordSet_ext_mysql extends ADORecordSet_mysql {
|
||||
function ADORecordSet_ext_mysql($queryID,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
$mode = $ADODB_FETCH_MODE;
|
||||
}
|
||||
@ -814,7 +814,7 @@ class ADORecordSet_ext_mysql extends ADORecordSet_mysql {
|
||||
$this->adodbFetchMode = $mode;
|
||||
$this->ADORecordSet($queryID);
|
||||
}
|
||||
|
||||
|
||||
function MoveNext()
|
||||
{
|
||||
return @adodb_movenext($this);
|
||||
|
Reference in New Issue
Block a user