mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-08-16 19:41:45 +02:00
imported ADOdb version 4.20 released 27 Feb 2004
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
V3.94 13 Oct 2003 (c) 2000-2003 John Lim (jlim@natsoft.com.my). All rights reserved.
|
||||
V4.20 22 Feb 2004 (c) 2000-2004 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,
|
||||
the BSD license will take precedence.
|
||||
@ -34,8 +34,8 @@ class ADODB_mysql extends ADOConnection {
|
||||
var $forceNewConnect = false;
|
||||
var $poorAffectedRows = true;
|
||||
var $clientFlags = 0;
|
||||
var $dbxDriver = 1;
|
||||
var $substr = "substring";
|
||||
var $nameQuote = '`'; /// string to use to quote identifiers and names
|
||||
|
||||
function ADODB_mysql()
|
||||
{
|
||||
@ -43,7 +43,7 @@ class ADODB_mysql extends ADOConnection {
|
||||
|
||||
function ServerInfo()
|
||||
{
|
||||
$arr['description'] = $this->GetOne("select version()");
|
||||
$arr['description'] = ADOConnection::GetOne("select version()");
|
||||
$arr['version'] = ADOConnection::_findvers($arr['description']);
|
||||
return $arr;
|
||||
}
|
||||
@ -68,6 +68,59 @@ class ADODB_mysql extends ADOConnection {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
function &MetaIndexes ($table, $primary = FALSE, $owner=false)
|
||||
{
|
||||
// save old fetch mode
|
||||
global $ADODB_FETCH_MODE;
|
||||
|
||||
$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)
|
||||
{
|
||||
@ -127,14 +180,19 @@ class ADODB_mysql extends ADOConnection {
|
||||
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);
|
||||
$holdtransOK = $this->_transOK; // save the current status
|
||||
$rs = @$this->Execute($getnext);
|
||||
if (!$rs) {
|
||||
if ($holdtransOK) $this->_transOK = true; //if the status was ok before reset
|
||||
$u = strtoupper($seqname);
|
||||
$this->Execute(sprintf($this->_genSeqSQL,$seqname));
|
||||
$this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
|
||||
@ -144,6 +202,7 @@ class ADODB_mysql extends ADOConnection {
|
||||
|
||||
if ($rs) $rs->Close();
|
||||
|
||||
$this->_logsql = $savelog;
|
||||
return $this->genID;
|
||||
}
|
||||
|
||||
@ -239,14 +298,6 @@ class ADODB_mysql extends ADOConnection {
|
||||
{
|
||||
$s = "";
|
||||
$arr = func_get_args();
|
||||
$first = true;
|
||||
/*
|
||||
foreach($arr as $a) {
|
||||
if ($first) {
|
||||
$s = $a;
|
||||
$first = false;
|
||||
} else $s .= ','.$a;
|
||||
}*/
|
||||
|
||||
// suggestion by andrew005@mnogo.ru
|
||||
$s = implode(',',$arr);
|
||||
@ -319,6 +370,21 @@ class ADODB_mysql extends ADOConnection {
|
||||
$fld->name = $rs->fields[0];
|
||||
$type = $rs->fields[1];
|
||||
|
||||
|
||||
// split type into type(length):
|
||||
$fld->scale = null;
|
||||
if (strpos($type,',') && preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
|
||||
$fld->type = $query_array[1];
|
||||
$fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
|
||||
$fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
|
||||
} elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
|
||||
$fld->type = $query_array[1];
|
||||
$fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
|
||||
} else {
|
||||
$fld->max_length = -1;
|
||||
$fld->type = $type;
|
||||
}
|
||||
/*
|
||||
// split type into type(length):
|
||||
if (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
|
||||
$fld->type = $query_array[1];
|
||||
@ -326,11 +392,12 @@ class ADODB_mysql extends ADOConnection {
|
||||
} else {
|
||||
$fld->max_length = -1;
|
||||
$fld->type = $type;
|
||||
}
|
||||
}*/
|
||||
$fld->not_null = ($rs->fields[2] != 'YES');
|
||||
$fld->primary_key = ($rs->fields[3] == 'PRI');
|
||||
$fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
|
||||
$fld->binary = (strpos($fld->type,'blob') !== false);
|
||||
|
||||
if (!$fld->binary) {
|
||||
$d = $rs->fields[4];
|
||||
if ($d != "" && $d != "NULL") {
|
||||
@ -365,9 +432,11 @@ class ADODB_mysql extends ADOConnection {
|
||||
{
|
||||
$offsetStr =($offset>=0) ? "$offset," : '';
|
||||
|
||||
return ($secs) ? $this->CacheExecute($secs,$sql." LIMIT $offsetStr$nrows",$inputarr)
|
||||
: $this->Execute($sql." LIMIT $offsetStr$nrows",$inputarr);
|
||||
|
||||
if ($secs)
|
||||
$rs =& $this->CacheExecute($secs,$sql." LIMIT $offsetStr$nrows",$inputarr);
|
||||
else
|
||||
$rs =& $this->Execute($sql." LIMIT $offsetStr$nrows",$inputarr);
|
||||
return $rs;
|
||||
}
|
||||
|
||||
|
||||
@ -483,7 +552,8 @@ class ADORecordSet_mysql extends ADORecordSet{
|
||||
function &GetRowAssoc($upper=true)
|
||||
{
|
||||
if ($this->fetchMode == MYSQL_ASSOC && !$upper) return $this->fields;
|
||||
return ADORecordSet::GetRowAssoc($upper);
|
||||
$row =& ADORecordSet::GetRowAssoc($upper);
|
||||
return $row;
|
||||
}
|
||||
|
||||
/* Use associative array to get fields array */
|
||||
@ -574,6 +644,7 @@ class ADORecordSet_mysql extends ADORecordSet{
|
||||
case 'BLOB':
|
||||
case 'MEDIUMBLOB':
|
||||
return !empty($fieldobj->binary) ? 'B' : 'X';
|
||||
|
||||
case 'YEAR':
|
||||
case 'DATE': return 'D';
|
||||
|
||||
|
Reference in New Issue
Block a user