Merge branch 'master_MDL-76906' of https://github.com/mattporritt/moodle
This commit is contained in:
@@ -501,7 +501,8 @@ class ADODB_Active_Record {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
foreach($cols as $name => $fldobj) {
|
||||
foreach($cols as $fldobj) {
|
||||
$name = $fldobj->name;
|
||||
|
||||
if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value)) {
|
||||
$this->$name = $fldobj->default_value;
|
||||
|
||||
@@ -76,7 +76,7 @@ $ADODB_INCLUDED_CSV = 1;
|
||||
|
||||
$savefetch = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode;
|
||||
$class = $rs->connection->arrayClass;
|
||||
$rs2 = new $class(-1); // Dummy query Id
|
||||
$rs2 = new $class(ADORecordSet::DUMMY_QUERY_ID);
|
||||
$rs2->timeCreated = $rs->timeCreated; # memcache fix
|
||||
$rs2->sql = $rs->sql;
|
||||
$rs2->oldProvider = $rs->dataProvider;
|
||||
|
||||
@@ -1007,11 +1007,17 @@ class ADODB_DataDict {
|
||||
}
|
||||
|
||||
/**
|
||||
"Florian Buzin [ easywe ]" <florian.buzin#easywe.de>
|
||||
|
||||
This function changes/adds new fields to your table. You don't
|
||||
have to know if the col is new or not. It will check on its own.
|
||||
*/
|
||||
* This function changes/adds new fields to your table.
|
||||
*
|
||||
* You don't have to know if the col is new or not. It will check on its own.
|
||||
*
|
||||
* @param string $tablename
|
||||
* @param string $flds
|
||||
* @param string[] $tableoptions
|
||||
* @param bool $dropOldFlds
|
||||
*
|
||||
* @return string[] Array of SQL Commands
|
||||
*/
|
||||
function changeTableSQL($tablename, $flds, $tableoptions = false, $dropOldFlds=false)
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
@@ -1070,37 +1076,14 @@ class ADODB_DataDict {
|
||||
$flds = $holdflds;
|
||||
}
|
||||
|
||||
|
||||
// already exists, alter table instead
|
||||
list($lines,$pkey,$idxs) = $this->_genFields($flds);
|
||||
// genfields can return FALSE at times
|
||||
if ($lines == null) $lines = array();
|
||||
$alter = 'ALTER TABLE ' . $this->tableName($tablename);
|
||||
$sql = array();
|
||||
|
||||
foreach ( $lines as $id => $v ) {
|
||||
if ( isset($cols[$id]) && is_object($cols[$id]) ) {
|
||||
|
||||
$flds = lens_ParseArgs($v,',');
|
||||
|
||||
// We are trying to change the size of the field, if not allowed, simply ignore the request.
|
||||
// $flds[1] holds the type, $flds[2] holds the size -postnuke addition
|
||||
if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4)
|
||||
&& (isset($flds[0][2]) && is_numeric($flds[0][2]))) {
|
||||
if ($this->debug) ADOConnection::outp(sprintf("<h3>%s cannot be changed to %s currently</h3>", $flds[0][0], $flds[0][1]));
|
||||
#echo "<h3>$this->alterCol cannot be changed to $flds currently</h3>";
|
||||
continue;
|
||||
}
|
||||
$sql[] = $alter . $this->alterCol . ' ' . $v;
|
||||
} else {
|
||||
$sql[] = $alter . $this->addCol . ' ' . $v;
|
||||
}
|
||||
}
|
||||
$sql = $this->alterColumnSql($tablename, $flds);
|
||||
|
||||
if ($dropOldFlds) {
|
||||
foreach ( $cols as $id => $v )
|
||||
if ( !isset($lines[$id]) )
|
||||
$sql[] = $alter . $this->dropCol . ' ' . $v->name;
|
||||
foreach ($cols as $id => $v) {
|
||||
if (!isset($lines[$id])) {
|
||||
$sql[] = $this->dropColumnSQL($tablename, $flds);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
+319
-293
@@ -27,44 +27,30 @@ if (!defined('ADODB_DIR')) die();
|
||||
global $ADODB_INCLUDED_LIB;
|
||||
$ADODB_INCLUDED_LIB = 1;
|
||||
|
||||
/**
|
||||
* Strip the ORDER BY clause from the outer SELECT.
|
||||
*
|
||||
* @param string $sql
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function adodb_strip_order_by($sql)
|
||||
{
|
||||
$rez = preg_match_all('/(\sORDER\s+BY\s(?:[^)](?!LIMIT))*)/is', $sql, $arr);
|
||||
if ($arr)
|
||||
{
|
||||
$tmp = array_pop($arr);
|
||||
$arr = [1=>array_pop($tmp)];
|
||||
}
|
||||
if ($arr)
|
||||
if (strpos($arr[1], '(') !== false) {
|
||||
$at = strpos($sql, $arr[1]);
|
||||
$cntin = 0;
|
||||
for ($i=$at, $max=strlen($sql); $i < $max; $i++) {
|
||||
$ch = $sql[$i];
|
||||
if ($ch == '(') {
|
||||
$cntin += 1;
|
||||
} elseif($ch == ')') {
|
||||
$cntin -= 1;
|
||||
if ($cntin < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql = substr($sql,0,$at).substr($sql,$i);
|
||||
} else {
|
||||
$sql = str_replace($arr[1], '', $sql);
|
||||
}
|
||||
$num = preg_match_all('/(\sORDER\s+BY\s(?:[^)](?!LIMIT))*)/is', $sql, $matches, PREG_OFFSET_CAPTURE);
|
||||
if ($num) {
|
||||
// Get the last match
|
||||
list($last_order_by, $offset) = array_pop($matches[1]);
|
||||
|
||||
// If we find a ')' after the last order by, then it belongs to a
|
||||
// sub-query, not the outer SQL statement and should not be stripped
|
||||
if (strpos($sql, ')', $offset) === false) {
|
||||
$sql = str_replace($last_order_by, '', $sql);
|
||||
}
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
if (false) {
|
||||
$sql = 'select * from (select a from b order by a(b),b(c) desc)';
|
||||
$sql = '(select * from abc order by 1)';
|
||||
die(adodb_strip_order_by($sql));
|
||||
}
|
||||
|
||||
function adodb_probetypes(&$array,&$types,$probe=8)
|
||||
function adodb_probetypes($array,&$types,$probe=8)
|
||||
{
|
||||
// probe and guess the type
|
||||
$types = array();
|
||||
@@ -96,7 +82,7 @@ function adodb_probetypes(&$array,&$types,$probe=8)
|
||||
// that it is not an integer
|
||||
if (strlen($v) == 0) $types[$i] = 'C';
|
||||
if (strpos($v,'.') !== false) $types[$i] = 'N';
|
||||
else $types[$i] = 'I';
|
||||
else $types[$i] = 'I';
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -107,7 +93,7 @@ function adodb_probetypes(&$array,&$types,$probe=8)
|
||||
|
||||
}
|
||||
|
||||
function adodb_transpose(&$arr, &$newarr, &$hdr, &$fobjs)
|
||||
function adodb_transpose(&$arr, &$newarr, &$hdr, $fobjs)
|
||||
{
|
||||
$oldX = sizeof(reset($arr));
|
||||
$oldY = sizeof($arr);
|
||||
@@ -135,7 +121,7 @@ function adodb_transpose(&$arr, &$newarr, &$hdr, &$fobjs)
|
||||
}
|
||||
|
||||
|
||||
function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc)
|
||||
function _adodb_replace($zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc)
|
||||
{
|
||||
// Add Quote around table name to support use of spaces / reserved keywords
|
||||
$table=sprintf('%s%s%s', $zthis->nameQuote,$table,$zthis->nameQuote);
|
||||
@@ -209,7 +195,7 @@ function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_
|
||||
return ($rs) ? 2 : 0;
|
||||
}
|
||||
|
||||
function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false,
|
||||
function _adodb_getmenu($zthis, $name,$defstr='',$blank1stItem=true,$multiple=false,
|
||||
$size=0, $selectAttr='',$compareFields0=true)
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
@@ -242,6 +228,7 @@ function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=f
|
||||
$value = 'value="' . htmlspecialchars($zval2) . '"';
|
||||
}
|
||||
|
||||
/** @noinspection PhpUndefinedVariableInspection */
|
||||
$s .= _adodb_getmenu_option($defstr, $compareFields0 ? $zval : $zval2, $value, $zval);
|
||||
|
||||
$zthis->MoveNext();
|
||||
@@ -250,7 +237,7 @@ function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=f
|
||||
return $s ."\n</select>\n";
|
||||
}
|
||||
|
||||
function _adodb_getmenu_gp(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false,
|
||||
function _adodb_getmenu_gp($zthis, $name,$defstr='',$blank1stItem=true,$multiple=false,
|
||||
$size=0, $selectAttr='',$compareFields0=true)
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
@@ -304,6 +291,7 @@ function _adodb_getmenu_gp(&$zthis, $name,$defstr='',$blank1stItem=true,$multipl
|
||||
$s .="\n<optgroup label='". htmlspecialchars($group) ."'>";
|
||||
}
|
||||
|
||||
/** @noinspection PhpUndefinedVariableInspection */
|
||||
$s .= _adodb_getmenu_option($defstr, $compareFields0 ? $zval : $zval2, $value, $zval);
|
||||
|
||||
$zthis->MoveNext();
|
||||
@@ -349,7 +337,7 @@ function _adodb_getmenu_select($name, $defstr = '', $blank1stItem = true,
|
||||
|
||||
$html = '<select name="' . $name . '"' . $attr . ' ' . $selectAttr . '>';
|
||||
if ($blank1stItem) {
|
||||
if (is_string($blank1stItem)) {
|
||||
if (is_string($blank1stItem)) {
|
||||
$barr = explode(':',$blank1stItem);
|
||||
if (sizeof($barr) == 1) {
|
||||
$barr[] = '';
|
||||
@@ -400,7 +388,7 @@ function _adodb_getmenu_option($defstr, $compare, $value, $display)
|
||||
$cnt = _adodb_getcount($conn, $sql);
|
||||
|
||||
*/
|
||||
function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
|
||||
function _adodb_getcount($zthis, $sql,$inputarr=false,$secs2cache=0)
|
||||
{
|
||||
$qryRecs = 0;
|
||||
|
||||
@@ -456,7 +444,7 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
|
||||
continue;
|
||||
}
|
||||
// Exit loop if 'FROM' keyword was found
|
||||
if (strtoupper(substr($sql, $pos, 4)) == 'FROM') {
|
||||
if (strtoupper(substr($sql, $pos, 4)) == 'FROM') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -491,7 +479,7 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
|
||||
if (preg_match('/\s*UNION\s*/is', $sql)) {
|
||||
$rewritesql = $sql;
|
||||
} else {
|
||||
$rewritesql = $rewritesql = adodb_strip_order_by($sql);
|
||||
$rewritesql = adodb_strip_order_by($sql);
|
||||
}
|
||||
|
||||
if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) {
|
||||
@@ -529,25 +517,20 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
|
||||
data will get out of synch. use CachePageExecute() only with tables that
|
||||
rarely change.
|
||||
*/
|
||||
function _adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page,
|
||||
function _adodb_pageexecute_all_rows($zthis, $sql, $nrows, $page,
|
||||
$inputarr=false, $secs2cache=0)
|
||||
{
|
||||
$atfirstpage = false;
|
||||
$atlastpage = false;
|
||||
$lastpageno=1;
|
||||
|
||||
// If an invalid nrows is supplied,
|
||||
// we assume a default value of 10 rows per page
|
||||
if (!isset($nrows) || $nrows <= 0) $nrows = 10;
|
||||
|
||||
$qryRecs = false; //count records for no offset
|
||||
|
||||
$qryRecs = _adodb_getcount($zthis,$sql,$inputarr,$secs2cache);
|
||||
$lastpageno = (int) ceil($qryRecs / $nrows);
|
||||
$zthis->_maxRecordCount = $qryRecs;
|
||||
|
||||
|
||||
|
||||
// ***** Here we check whether $page is the last page or
|
||||
// whether we are trying to retrieve
|
||||
// a page number greater than the last page number.
|
||||
@@ -583,9 +566,8 @@ function _adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page,
|
||||
}
|
||||
|
||||
// Iván Oliva version
|
||||
function _adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0)
|
||||
function _adodb_pageexecute_no_last_page($zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0)
|
||||
{
|
||||
|
||||
$atfirstpage = false;
|
||||
$atlastpage = false;
|
||||
|
||||
@@ -623,7 +605,6 @@ function _adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr
|
||||
// page and return it. Revert to original method and loop through pages
|
||||
// until we find some data...
|
||||
$pagecounter = $page + 1;
|
||||
$pagecounteroffset = ($pagecounter * $nrows) - $nrows;
|
||||
|
||||
$rstest = $rsreturn;
|
||||
if ($rstest) {
|
||||
@@ -715,7 +696,7 @@ function _adodb_quote_fieldname($zthis, $fieldName)
|
||||
}
|
||||
}
|
||||
|
||||
function _adodb_getupdatesql(&$zthis, &$rs, $arrFields, $forceUpdate=false, $force=2)
|
||||
function _adodb_getupdatesql(&$zthis, $rs, $arrFields, $forceUpdate=false, $force=2)
|
||||
{
|
||||
if (!$rs) {
|
||||
printf(ADODB_BAD_RS,'GetUpdateSQL');
|
||||
@@ -746,11 +727,11 @@ function _adodb_getupdatesql(&$zthis, &$rs, $arrFields, $forceUpdate=false, $for
|
||||
|
||||
if ($hasnumeric) $val = $rs->fields[$i];
|
||||
else if (isset($rs->fields[$upperfname])) $val = $rs->fields[$upperfname];
|
||||
else if (isset($rs->fields[$field->name])) $val = $rs->fields[$field->name];
|
||||
else if (isset($rs->fields[strtolower($upperfname)])) $val = $rs->fields[strtolower($upperfname)];
|
||||
else if (isset($rs->fields[$field->name])) $val = $rs->fields[$field->name];
|
||||
else if (isset($rs->fields[strtolower($upperfname)])) $val = $rs->fields[strtolower($upperfname)];
|
||||
else $val = '';
|
||||
|
||||
if ($forceUpdate || strcmp($val, $arrFields[$upperfname])) {
|
||||
if ($forceUpdate || $val !== $arrFields[$upperfname]) {
|
||||
// Set the counter for the number of fields that will be updated.
|
||||
$fieldUpdatedCount++;
|
||||
|
||||
@@ -840,7 +821,6 @@ function _adodb_getupdatesql(&$zthis, &$rs, $arrFields, $forceUpdate=false, $for
|
||||
$discard = false;
|
||||
// not a good hack, improvements?
|
||||
if ($whereClause) {
|
||||
#var_dump($whereClause);
|
||||
if (preg_match('/\s(ORDER\s.*)/is', $whereClause[1], $discard));
|
||||
else if (preg_match('/\s(LIMIT\s.*)/is', $whereClause[1], $discard));
|
||||
else if (preg_match('/\s(FOR UPDATE.*)/is', $whereClause[1], $discard));
|
||||
@@ -863,14 +843,14 @@ function _adodb_getupdatesql(&$zthis, &$rs, $arrFields, $forceUpdate=false, $for
|
||||
}
|
||||
}
|
||||
|
||||
function adodb_key_exists($key, &$arr,$force=2)
|
||||
function adodb_key_exists($key, $arr,$force=2)
|
||||
{
|
||||
if ($force<=0) {
|
||||
// the following is the old behaviour where null or empty fields are ignored
|
||||
return (!empty($arr[$key])) || (isset($arr[$key]) && strlen($arr[$key])>0);
|
||||
}
|
||||
|
||||
if (isset($arr[$key]))
|
||||
if (isset($arr[$key]))
|
||||
return true;
|
||||
## null check below
|
||||
return array_key_exists($key,$arr);
|
||||
@@ -883,7 +863,7 @@ function adodb_key_exists($key, &$arr,$force=2)
|
||||
*
|
||||
*
|
||||
*/
|
||||
function _adodb_getinsertsql(&$zthis, &$rs, $arrFields, $force=2)
|
||||
function _adodb_getinsertsql(&$zthis, $rs, $arrFields, $force=2)
|
||||
{
|
||||
static $cacheRS = false;
|
||||
static $cacheSig = 0;
|
||||
@@ -892,7 +872,6 @@ static $cacheCols;
|
||||
$tableName = '';
|
||||
$values = '';
|
||||
$fields = '';
|
||||
$recordSet = null;
|
||||
if (is_array($arrFields))
|
||||
$arrFields = array_change_key_case($arrFields,CASE_UPPER);
|
||||
$fieldInsertedCount = 0;
|
||||
@@ -906,7 +885,7 @@ static $cacheCols;
|
||||
//because we have to call MetaType.
|
||||
//php can't do a $rsclass::MetaType()
|
||||
$rsclass = $zthis->rsPrefix.$zthis->databaseType;
|
||||
$recordSet = new $rsclass(-1,$zthis->fetchMode);
|
||||
$recordSet = new $rsclass(ADORecordSet::DUMMY_QUERY_ID, $zthis->fetchMode);
|
||||
$recordSet->connection = $zthis;
|
||||
|
||||
if (is_string($cacheRS) && $cacheRS == $rs) {
|
||||
@@ -920,6 +899,7 @@ static $cacheCols;
|
||||
if (isset($rs->insertSig) && is_integer($cacheRS) && $cacheRS == $rs->insertSig) {
|
||||
$columns = $cacheCols;
|
||||
} else {
|
||||
$columns = [];
|
||||
for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++)
|
||||
$columns[] = $rs->FetchField($i);
|
||||
$cacheRS = $cacheSig;
|
||||
@@ -936,60 +916,58 @@ static $cacheCols;
|
||||
// Loop through all of the fields in the recordset
|
||||
foreach( $columns as $field ) {
|
||||
$upperfname = strtoupper($field->name);
|
||||
if (adodb_key_exists($upperfname,$arrFields,$force)) {
|
||||
if (adodb_key_exists($upperfname, $arrFields, $force)) {
|
||||
$bad = false;
|
||||
$fnameq = _adodb_quote_fieldname($zthis, $field->name);
|
||||
$type = $recordSet->MetaType($field->type);
|
||||
|
||||
/********************************************************/
|
||||
if (is_null($arrFields[$upperfname])
|
||||
|| (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0)
|
||||
|| $arrFields[$upperfname] === $zthis->null2null
|
||||
)
|
||||
{
|
||||
switch ($force) {
|
||||
/********************************************************/
|
||||
if (is_null($arrFields[$upperfname])
|
||||
|| (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0)
|
||||
|| $arrFields[$upperfname] === $zthis->null2null
|
||||
) {
|
||||
switch ($force) {
|
||||
|
||||
case ADODB_FORCE_IGNORE: // we must always set null if missing
|
||||
$bad = true;
|
||||
break;
|
||||
|
||||
case ADODB_FORCE_NULL:
|
||||
$values .= "null, ";
|
||||
break;
|
||||
|
||||
case ADODB_FORCE_EMPTY:
|
||||
//Set empty
|
||||
$arrFields[$upperfname] = "";
|
||||
$values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields);
|
||||
break;
|
||||
|
||||
default:
|
||||
case ADODB_FORCE_VALUE:
|
||||
//Set the value that was given in array, so you can give both null and empty values
|
||||
if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === $zthis->null2null) {
|
||||
$values .= "null, ";
|
||||
} else {
|
||||
$values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields);
|
||||
}
|
||||
break;
|
||||
|
||||
case ADODB_FORCE_NULL_AND_ZERO:
|
||||
switch ($type)
|
||||
{
|
||||
case 'N':
|
||||
case 'I':
|
||||
case 'L':
|
||||
$values .= '0, ';
|
||||
break;
|
||||
default:
|
||||
$values .= "null, ";
|
||||
break;
|
||||
}
|
||||
case ADODB_FORCE_IGNORE: // we must always set null if missing
|
||||
$bad = true;
|
||||
break;
|
||||
|
||||
} // switch
|
||||
case ADODB_FORCE_NULL:
|
||||
$values .= "null, ";
|
||||
break;
|
||||
|
||||
/*********************************************************/
|
||||
case ADODB_FORCE_EMPTY:
|
||||
//Set empty
|
||||
$arrFields[$upperfname] = "";
|
||||
$values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields);
|
||||
break;
|
||||
|
||||
default:
|
||||
case ADODB_FORCE_VALUE:
|
||||
//Set the value that was given in array, so you can give both null and empty values
|
||||
if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === $zthis->null2null) {
|
||||
$values .= "null, ";
|
||||
} else {
|
||||
$values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields);
|
||||
}
|
||||
break;
|
||||
|
||||
case ADODB_FORCE_NULL_AND_ZERO:
|
||||
switch ($type) {
|
||||
case 'N':
|
||||
case 'I':
|
||||
case 'L':
|
||||
$values .= '0, ';
|
||||
break;
|
||||
default:
|
||||
$values .= "null, ";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
} // switch
|
||||
|
||||
/*********************************************************/
|
||||
} else {
|
||||
//we do this so each driver can customize the sql for
|
||||
//DB specific column types.
|
||||
@@ -998,11 +976,12 @@ static $cacheCols;
|
||||
$values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields);
|
||||
}
|
||||
|
||||
if ($bad) continue;
|
||||
if ($bad) {
|
||||
continue;
|
||||
}
|
||||
// Set the counter for the number of fields that will be inserted.
|
||||
$fieldInsertedCount++;
|
||||
|
||||
|
||||
// Get the name of the fields to insert
|
||||
$fields .= $fnameq . ", ";
|
||||
}
|
||||
@@ -1010,7 +989,7 @@ static $cacheCols;
|
||||
|
||||
|
||||
// If there were any inserted fields then build the rest of the insert query.
|
||||
if ($fieldInsertedCount <= 0) return false;
|
||||
if ($fieldInsertedCount <= 0) return false;
|
||||
|
||||
// Get the table name from the existing query.
|
||||
if (!$tableName) {
|
||||
@@ -1048,76 +1027,76 @@ static $cacheCols;
|
||||
*/
|
||||
function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $fnameq, $arrFields)
|
||||
{
|
||||
$sql = '';
|
||||
// Based on the datatype of the field
|
||||
// Format the value properly for the database
|
||||
switch ($type) {
|
||||
case 'B':
|
||||
//in order to handle Blobs correctly, we need
|
||||
//to do some magic for Oracle
|
||||
|
||||
// Based on the datatype of the field
|
||||
// Format the value properly for the database
|
||||
switch($type) {
|
||||
case 'B':
|
||||
//in order to handle Blobs correctly, we need
|
||||
//to do some magic for Oracle
|
||||
//we need to create a new descriptor to handle
|
||||
//this properly
|
||||
if (!empty($zthis->hasReturningInto)) {
|
||||
if ($action == 'I') {
|
||||
$sql = 'empty_blob(), ';
|
||||
} else {
|
||||
$sql = $fnameq . '=empty_blob(), ';
|
||||
}
|
||||
//add the variable to the returning clause array
|
||||
//so the user can build this later in
|
||||
//case they want to add more to it
|
||||
$zthis->_returningArray[$fname] = ':xx' . $fname . 'xx';
|
||||
} else {
|
||||
if (empty($arrFields[$fname])) {
|
||||
if ($action == 'I') {
|
||||
$sql = 'empty_blob(), ';
|
||||
} else {
|
||||
$sql = $fnameq . '=empty_blob(), ';
|
||||
}
|
||||
} else {
|
||||
//this is to maintain compatibility
|
||||
//with older adodb versions.
|
||||
$sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//we need to create a new descriptor to handle
|
||||
//this properly
|
||||
if (!empty($zthis->hasReturningInto)) {
|
||||
if ($action == 'I') {
|
||||
$sql = 'empty_blob(), ';
|
||||
} else {
|
||||
$sql = $fnameq. '=empty_blob(), ';
|
||||
}
|
||||
//add the variable to the returning clause array
|
||||
//so the user can build this later in
|
||||
//case they want to add more to it
|
||||
$zthis->_returningArray[$fname] = ':xx'.$fname.'xx';
|
||||
} else if (empty($arrFields[$fname])){
|
||||
if ($action == 'I') {
|
||||
$sql = 'empty_blob(), ';
|
||||
} else {
|
||||
$sql = $fnameq. '=empty_blob(), ';
|
||||
}
|
||||
} else {
|
||||
//this is to maintain compatibility
|
||||
//with older adodb versions.
|
||||
case "X":
|
||||
//we need to do some more magic here for long variables
|
||||
//to handle these correctly in oracle.
|
||||
|
||||
//create a safe bind var name
|
||||
//to avoid conflicts w/ dupes.
|
||||
if (!empty($zthis->hasReturningInto)) {
|
||||
if ($action == 'I') {
|
||||
$sql = ':xx' . $fname . 'xx, ';
|
||||
} else {
|
||||
$sql = $fnameq . '=:xx' . $fname . 'xx, ';
|
||||
}
|
||||
//add the variable to the returning clause array
|
||||
//so the user can build this later in
|
||||
//case they want to add more to it
|
||||
$zthis->_returningArray[$fname] = ':xx' . $fname . 'xx';
|
||||
} else {
|
||||
//this is to maintain compatibility
|
||||
//with older adodb versions.
|
||||
$sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, false);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, false);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
case "X":
|
||||
//we need to do some more magic here for long variables
|
||||
//to handle these correctly in oracle.
|
||||
|
||||
//create a safe bind var name
|
||||
//to avoid conflicts w/ dupes.
|
||||
if (!empty($zthis->hasReturningInto)) {
|
||||
if ($action == 'I') {
|
||||
$sql = ':xx'.$fname.'xx, ';
|
||||
} else {
|
||||
$sql = $fnameq.'=:xx'.$fname.'xx, ';
|
||||
}
|
||||
//add the variable to the returning clause array
|
||||
//so the user can build this later in
|
||||
//case they want to add more to it
|
||||
$zthis->_returningArray[$fname] = ':xx'.$fname.'xx';
|
||||
} else {
|
||||
//this is to maintain compatibility
|
||||
//with older adodb versions.
|
||||
$sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, false);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, false);
|
||||
break;
|
||||
}
|
||||
|
||||
return $sql;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function _adodb_column_sql(&$zthis, $action, $type, $fname, $fnameq, $arrFields, $recurse=true)
|
||||
{
|
||||
|
||||
if ($recurse) {
|
||||
switch($zthis->dataProvider) {
|
||||
switch($zthis->dataProvider) {
|
||||
case 'postgres':
|
||||
if ($type == 'L') $type = 'C';
|
||||
break;
|
||||
@@ -1143,15 +1122,15 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $fnameq, $arrFields,
|
||||
break;
|
||||
|
||||
case "N":
|
||||
$val = $arrFields[$fname];
|
||||
$val = $arrFields[$fname];
|
||||
if (!is_numeric($val)) $val = str_replace(',', '.', (float)$val);
|
||||
break;
|
||||
break;
|
||||
|
||||
case "I":
|
||||
case "R":
|
||||
$val = $arrFields[$fname];
|
||||
$val = $arrFields[$fname];
|
||||
if (!is_numeric($val)) $val = (integer) $val;
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
$val = str_replace(array("'"," ","("),"",$arrFields[$fname]); // basic sql injection defence
|
||||
@@ -1161,178 +1140,225 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $fnameq, $arrFields,
|
||||
|
||||
if ($action == 'I') return $val . ", ";
|
||||
|
||||
return $fnameq . "=" . $val . ", ";
|
||||
return $fnameq . "=" . $val . ", ";
|
||||
}
|
||||
|
||||
|
||||
|
||||
function _adodb_debug_execute(&$zthis, $sql, $inputarr)
|
||||
/**
|
||||
* Replaces standard _execute when debug mode is enabled
|
||||
*
|
||||
* @param ADOConnection $zthis An ADOConnection object
|
||||
* @param string|string[] $sql A string or array of SQL statements
|
||||
* @param string[]|null $inputarr An optional array of bind parameters
|
||||
*
|
||||
* @return handle|void A handle to the executed query
|
||||
*/
|
||||
function _adodb_debug_execute($zthis, $sql, $inputarr)
|
||||
{
|
||||
// Unpack the bind parameters
|
||||
$ss = '';
|
||||
if ($inputarr) {
|
||||
foreach($inputarr as $kk=>$vv) {
|
||||
if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).'...';
|
||||
if (is_null($vv)) $ss .= "($kk=>null) ";
|
||||
else
|
||||
{
|
||||
if (is_array($vv))
|
||||
{
|
||||
$vv = sprintf("Array Of Values: [%s]", implode(',',$vv));
|
||||
foreach ($inputarr as $kk => $vv) {
|
||||
if (is_string($vv) && strlen($vv) > 64) {
|
||||
$vv = substr($vv, 0, 64) . '...';
|
||||
}
|
||||
if (is_null($vv)) {
|
||||
$ss .= "($kk=>null) ";
|
||||
} else {
|
||||
if (is_array($vv)) {
|
||||
$vv = sprintf("Array Of Values: [%s]", implode(',', $vv));
|
||||
}
|
||||
$ss .= "($kk=>'$vv') ";
|
||||
}
|
||||
}
|
||||
|
||||
$ss = "[ $ss ]";
|
||||
}
|
||||
|
||||
$sqlTxt = is_array($sql) ? $sql[0] : $sql;
|
||||
/*str_replace(', ','##1#__^LF',is_array($sql) ? $sql[0] : $sql);
|
||||
$sqlTxt = str_replace(',',', ',$sqlTxt);
|
||||
$sqlTxt = str_replace('##1#__^LF', ', ' ,$sqlTxt);
|
||||
*/
|
||||
|
||||
// Remove newlines and tabs, compress repeating spaces
|
||||
$sqlTxt = preg_replace('/\s+/', ' ', $sqlTxt);
|
||||
|
||||
// check if running from browser or command-line
|
||||
$inBrowser = isset($_SERVER['HTTP_USER_AGENT']);
|
||||
|
||||
$dbt = $zthis->databaseType;
|
||||
if (isset($zthis->dsnType)) $dbt .= '-'.$zthis->dsnType;
|
||||
$myDatabaseType = $zthis->databaseType;
|
||||
if (!isset($zthis->dsnType)) {
|
||||
// Append the PDO driver name
|
||||
$myDatabaseType .= '-' . $zthis->dsnType;
|
||||
}
|
||||
|
||||
if ($inBrowser) {
|
||||
if ($ss) {
|
||||
$ss = '<code>'.htmlspecialchars($ss).'</code>';
|
||||
// Default formatting for passed parameter
|
||||
$ss = sprintf('<code class="adodb-debug">%s</code>', htmlspecialchars($ss));
|
||||
}
|
||||
if ($zthis->debug === -1) {
|
||||
$outString = "<br class='adodb-debug'>(%s): %s %s<br class='adodb-debug'>";
|
||||
ADOConnection::outp(sprintf($outString, $myDatabaseType, htmlspecialchars($sqlTxt), $ss), false);
|
||||
} elseif ($zthis->debug !== -99) {
|
||||
$outString = "<hr class='adodb-debug'>(%s): %s %s<hr class='adodb-debug'>";
|
||||
ADOConnection::outp(sprintf($outString, $myDatabaseType, htmlspecialchars($sqlTxt), $ss), false);
|
||||
}
|
||||
if ($zthis->debug === -1)
|
||||
ADOConnection::outp( "<br>\n($dbt): ".htmlspecialchars($sqlTxt)." $ss\n<br>\n",false);
|
||||
else if ($zthis->debug !== -99)
|
||||
ADOConnection::outp( "<hr>\n($dbt): ".htmlspecialchars($sqlTxt)." $ss\n<hr>\n",false);
|
||||
} else {
|
||||
$ss = "\n ".$ss;
|
||||
if ($zthis->debug !== -99)
|
||||
ADOConnection::outp("-----<hr>\n($dbt): ".$sqlTxt." $ss\n-----<hr>\n",false);
|
||||
// CLI output
|
||||
if ($zthis->debug !== -99) {
|
||||
$outString = sprintf("%s\n%s\n %s %s \n%s\n", str_repeat('-', 78), $myDatabaseType, $sqlTxt, $ss, str_repeat('-', 78));
|
||||
ADOConnection::outp($outString, false);
|
||||
}
|
||||
}
|
||||
|
||||
$qID = $zthis->_query($sql,$inputarr);
|
||||
// Now execute the query
|
||||
$qID = $zthis->_query($sql, $inputarr);
|
||||
|
||||
/*
|
||||
Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql
|
||||
because ErrorNo() calls Execute('SELECT @ERROR'), causing recursion
|
||||
*/
|
||||
// Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql
|
||||
// because ErrorNo() calls Execute('SELECT @ERROR'), causing recursion
|
||||
if ($zthis->databaseType == 'mssql') {
|
||||
// ErrorNo is a slow function call in mssql, and not reliable in PHP 4.0.6
|
||||
|
||||
if($emsg = $zthis->ErrorMsg()) {
|
||||
// ErrorNo is a slow function call in mssql
|
||||
if ($emsg = $zthis->ErrorMsg()) {
|
||||
if ($err = $zthis->ErrorNo()) {
|
||||
if ($zthis->debug === -99)
|
||||
ADOConnection::outp( "<hr>\n($dbt): ".htmlspecialchars($sqlTxt)." $ss\n<hr>\n",false);
|
||||
if ($zthis->debug === -99) {
|
||||
ADOConnection::outp("<hr>\n($myDatabaseType): " . htmlspecialchars($sqlTxt) . " $ss\n<hr>\n", false);
|
||||
}
|
||||
|
||||
ADOConnection::outp($err.': '.$emsg);
|
||||
ADOConnection::outp($err . ': ' . $emsg);
|
||||
}
|
||||
}
|
||||
} else if (!$qID) {
|
||||
} else {
|
||||
if (!$qID) {
|
||||
// Statement execution has failed
|
||||
if ($zthis->debug === -99) {
|
||||
if ($inBrowser) {
|
||||
$outString = "<hr class='adodb-debug'>(%s): %s %s<hr class='adodb-debug'>";
|
||||
ADOConnection::outp(sprintf($outString, $myDatabaseType, htmlspecialchars($sqlTxt), $ss), false);
|
||||
} else {
|
||||
$outString = sprintf("%s\n%s\n %s %s \n%s\n",str_repeat('-',78),$myDatabaseType,$sqlTxt,$ss,str_repeat('-',78));
|
||||
ADOConnection::outp($outString, false);
|
||||
}
|
||||
}
|
||||
|
||||
if ($zthis->debug === -99)
|
||||
if ($inBrowser) ADOConnection::outp( "<hr>\n($dbt): ".htmlspecialchars($sqlTxt)." $ss\n<hr>\n",false);
|
||||
else ADOConnection::outp("-----<hr>\n($dbt): ".$sqlTxt."$ss\n-----<hr>\n",false);
|
||||
|
||||
ADOConnection::outp($zthis->ErrorNo() .': '. $zthis->ErrorMsg());
|
||||
// Send last error to output
|
||||
$errno = $zthis->ErrorNo();
|
||||
if ($errno) {
|
||||
ADOConnection::outp($errno . ': ' . $zthis->ErrorMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($zthis->debug === 99) _adodb_backtrace(true,9999,2);
|
||||
if ($qID === false || $zthis->debug === 99) {
|
||||
_adodb_backtrace();
|
||||
}
|
||||
return $qID;
|
||||
}
|
||||
|
||||
# pretty print the debug_backtrace function
|
||||
function _adodb_backtrace($printOrArr=true,$levels=9999,$skippy=0,$ishtml=null)
|
||||
/**
|
||||
* Pretty print the debug_backtrace function
|
||||
*
|
||||
* @param string[]|bool $printOrArr Whether to print the result directly or return the result
|
||||
* @param int $maximumDepth The maximum depth of the array to traverse
|
||||
* @param int $elementsToIgnore The backtrace array indexes to ignore
|
||||
* @param null|bool $ishtml True if we are in a CGI environment, false for CLI,
|
||||
* null to auto detect
|
||||
*
|
||||
* @return string Formatted backtrace
|
||||
*/
|
||||
function _adodb_backtrace($printOrArr=true, $maximumDepth=9999, $elementsToIgnore=0, $ishtml=null)
|
||||
{
|
||||
if (!function_exists('debug_backtrace')) return '';
|
||||
if (!function_exists('debug_backtrace')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($ishtml === null) $html = (isset($_SERVER['HTTP_USER_AGENT']));
|
||||
else $html = $ishtml;
|
||||
if ($ishtml === null) {
|
||||
// Auto determine if we in a CGI enviroment
|
||||
$html = (isset($_SERVER['HTTP_USER_AGENT']));
|
||||
} else {
|
||||
$html = $ishtml;
|
||||
}
|
||||
|
||||
$fmt = ($html) ? "</font><font color=#808080 size=-1> %% line %4d, file: <a href=\"file:/%s\">%s</a></font>" : "%% line %4d, file: %s";
|
||||
$cgiString = "</font><font color=#808080 size=-1> %% line %4d, file: <a href=\"file:/%s\">%s</a></font>";
|
||||
$cliString = "%% line %4d, file: %s";
|
||||
$fmt = ($html) ? $cgiString : $cliString;
|
||||
|
||||
$MAXSTRLEN = 128;
|
||||
|
||||
$s = ($html) ? '<pre align=left>' : '';
|
||||
|
||||
if (is_array($printOrArr)) $traceArr = $printOrArr;
|
||||
else $traceArr = debug_backtrace();
|
||||
if (is_array($printOrArr)) {
|
||||
$traceArr = $printOrArr;
|
||||
} else {
|
||||
$traceArr = debug_backtrace();
|
||||
}
|
||||
|
||||
// Remove first 2 elements that just show calls to adodb_backtrace
|
||||
array_shift($traceArr);
|
||||
array_shift($traceArr);
|
||||
$tabs = sizeof($traceArr)-2;
|
||||
|
||||
// We want last element to have no indent
|
||||
$tabs = sizeof($traceArr) - 1;
|
||||
|
||||
foreach ($traceArr as $arr) {
|
||||
if ($skippy) {$skippy -= 1; continue;}
|
||||
$levels -= 1;
|
||||
if ($levels < 0) break;
|
||||
if ($elementsToIgnore) {
|
||||
// Ignore array element at start of array
|
||||
$elementsToIgnore--;
|
||||
$tabs--;
|
||||
continue;
|
||||
}
|
||||
$maximumDepth--;
|
||||
if ($maximumDepth < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
$args = array();
|
||||
for ($i=0; $i < $tabs; $i++) $s .= ($html) ? ' ' : "\t";
|
||||
$tabs -= 1;
|
||||
if ($html) $s .= '<font face="Courier New,Courier">';
|
||||
if (isset($arr['class'])) $s .= $arr['class'].'.';
|
||||
if (isset($arr['args']))
|
||||
foreach($arr['args'] as $v) {
|
||||
if (is_null($v)) $args[] = 'null';
|
||||
else if (is_array($v)) $args[] = 'Array['.sizeof($v).']';
|
||||
else if (is_object($v)) $args[] = 'Object:'.get_class($v);
|
||||
else if (is_bool($v)) $args[] = $v ? 'true' : 'false';
|
||||
else {
|
||||
$v = (string) @$v;
|
||||
$str = htmlspecialchars(str_replace(array("\r","\n"),' ',substr($v,0,$MAXSTRLEN)));
|
||||
if (strlen($v) > $MAXSTRLEN) $str .= '...';
|
||||
$args[] = $str;
|
||||
|
||||
if ($tabs) {
|
||||
$s .= str_repeat($html ? ' ' : "\t", $tabs);
|
||||
$tabs--;
|
||||
}
|
||||
if ($html) {
|
||||
$s .= '<font face="Courier New,Courier">';
|
||||
}
|
||||
|
||||
if (isset($arr['class'])) {
|
||||
$s .= $arr['class'] . '.';
|
||||
}
|
||||
|
||||
if (isset($arr['args'])) {
|
||||
foreach ($arr['args'] as $v) {
|
||||
if (is_null($v)) {
|
||||
$args[] = 'null';
|
||||
} elseif (is_array($v)) {
|
||||
$args[] = 'Array[' . sizeof($v) . ']';
|
||||
} elseif (is_object($v)) {
|
||||
$args[] = 'Object:' . get_class($v);
|
||||
} elseif (is_bool($v)) {
|
||||
$args[] = $v ? 'true' : 'false';
|
||||
} else {
|
||||
$v = (string)@$v;
|
||||
// Truncate
|
||||
$v = substr($v, 0, $MAXSTRLEN);
|
||||
// Remove newlines and tabs, compress repeating spaces
|
||||
$v = preg_replace('/\s+/', ' ', $v);
|
||||
// Convert htmlchars (not sure why we do this in CLI)
|
||||
$str = htmlspecialchars($v);
|
||||
|
||||
if (strlen($v) > $MAXSTRLEN) {
|
||||
$str .= '...';
|
||||
}
|
||||
|
||||
$args[] = $str;
|
||||
}
|
||||
}
|
||||
}
|
||||
$s .= $arr['function'].'('.implode(', ',$args).')';
|
||||
|
||||
|
||||
$s .= @sprintf($fmt, $arr['line'],$arr['file'],basename($arr['file']));
|
||||
|
||||
$s .= $arr['function'] . '(' . implode(', ', $args) . ')';
|
||||
$s .= @sprintf($fmt, $arr['line'], $arr['file'], basename($arr['file']));
|
||||
$s .= "\n";
|
||||
}
|
||||
if ($html) $s .= '</pre>';
|
||||
if ($printOrArr) print $s;
|
||||
if ($html) {
|
||||
$s .= '</pre>';
|
||||
}
|
||||
if ($printOrArr) {
|
||||
print $s;
|
||||
}
|
||||
|
||||
return $s;
|
||||
}
|
||||
/*
|
||||
function _adodb_find_from($sql)
|
||||
{
|
||||
|
||||
$sql = str_replace(array("\n","\r"), ' ', $sql);
|
||||
$charCount = strlen($sql);
|
||||
|
||||
$inString = false;
|
||||
$quote = '';
|
||||
$parentheseCount = 0;
|
||||
$prevChars = '';
|
||||
$nextChars = '';
|
||||
|
||||
|
||||
for($i = 0; $i < $charCount; $i++) {
|
||||
|
||||
$char = substr($sql,$i,1);
|
||||
$prevChars = substr($sql,0,$i);
|
||||
$nextChars = substr($sql,$i+1);
|
||||
|
||||
if((($char == "'" || $char == '"' || $char == '`') && substr($prevChars,-1,1) != '\\') && $inString === false) {
|
||||
$quote = $char;
|
||||
$inString = true;
|
||||
}
|
||||
|
||||
elseif((($char == "'" || $char == '"' || $char == '`') && substr($prevChars,-1,1) != '\\') && $inString === true && $quote == $char) {
|
||||
$quote = "";
|
||||
$inString = false;
|
||||
}
|
||||
|
||||
elseif($char == "(" && $inString === false)
|
||||
$parentheseCount++;
|
||||
|
||||
elseif($char == ")" && $inString === false && $parentheseCount > 0)
|
||||
$parentheseCount--;
|
||||
|
||||
elseif($parentheseCount <= 0 && $inString === false && $char == " " && strtoupper(substr($prevChars,-5,5)) == " FROM")
|
||||
return $i;
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
+11
-6
@@ -198,7 +198,7 @@ if (!defined('_ADODB_LAYER')) {
|
||||
/**
|
||||
* ADODB version as a string.
|
||||
*/
|
||||
$ADODB_vers = 'v5.22.2 2022-05-08';
|
||||
$ADODB_vers = 'v5.22.4 2022-10-28';
|
||||
|
||||
/**
|
||||
* Determines whether recordset->RecordCount() is used.
|
||||
@@ -1556,9 +1556,6 @@ if (!defined('_ADODB_LAYER')) {
|
||||
|
||||
// error handling if query fails
|
||||
if ($this->_queryID === false) {
|
||||
if ($this->debug == 99) {
|
||||
adodb_backtrace(true,5);
|
||||
}
|
||||
$fn = $this->raiseErrorFn;
|
||||
if ($fn) {
|
||||
$fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr,$this);
|
||||
@@ -3875,6 +3872,10 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
|
||||
* means recordcount not known).
|
||||
*/
|
||||
class ADORecordSet implements IteratorAggregate {
|
||||
/**
|
||||
* Used for cases when a recordset object is not created by executing a query.
|
||||
*/
|
||||
const DUMMY_QUERY_ID = -1;
|
||||
|
||||
/**
|
||||
* public variables
|
||||
@@ -3902,8 +3903,12 @@ class ADORecordSet implements IteratorAggregate {
|
||||
*/
|
||||
var $_numOfRows = -1; /** number of rows, or -1 */
|
||||
var $_numOfFields = -1; /** number of fields in recordset */
|
||||
/** @var resource result link identifier */
|
||||
var $_queryID = -1;
|
||||
|
||||
/**
|
||||
* @var resource|int|false result link identifier
|
||||
*/
|
||||
var $_queryID = self::DUMMY_QUERY_ID;
|
||||
|
||||
var $_currentRow = -1; /** This variable keeps the current row in the Recordset. */
|
||||
var $_closed = false; /** has recordset been closed */
|
||||
var $_inited = false; /** Init() should only be called once */
|
||||
|
||||
@@ -517,6 +517,12 @@ class ADODB_firebird extends ADOConnection {
|
||||
}
|
||||
$ret = call_user_func_array($fn, $args);
|
||||
|
||||
// fbird_query() and fbird_execute() return number of affected rows
|
||||
// ADOConnection::_Execute() expects true for INSERT/UPDATE/DELETE
|
||||
if (is_numeric($ret)) {
|
||||
$ret = true;
|
||||
}
|
||||
|
||||
if ($docommit && $ret === true) {
|
||||
fbird_commit($this->_connectionID);
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ class ADODB_ibase extends ADOConnection {
|
||||
|
||||
function ErrorMsg()
|
||||
{
|
||||
return $this->_errorMsg;
|
||||
return $this->_errorMsg;
|
||||
}
|
||||
|
||||
function Prepare($sql)
|
||||
@@ -334,7 +334,6 @@ class ADODB_ibase extends ADOConnection {
|
||||
// there have been reports of problems with nested queries - the code is probably not re-entrant?
|
||||
function _query($sql,$iarr=false)
|
||||
{
|
||||
|
||||
if (!$this->autoCommit && $this->_transactionID) {
|
||||
$conn = $this->_transactionID;
|
||||
$docommit = false;
|
||||
@@ -346,27 +345,34 @@ class ADODB_ibase extends ADOConnection {
|
||||
$fn = 'ibase_execute';
|
||||
$sql = $sql[1];
|
||||
if (is_array($iarr)) {
|
||||
if ( !isset($iarr[0]) )
|
||||
$iarr[0] = ''; // PHP5 compat hack
|
||||
$fnarr = array_merge( array($sql) , $iarr);
|
||||
$ret = call_user_func_array($fn,$fnarr);
|
||||
}
|
||||
else {
|
||||
if (!isset($iarr[0])) {
|
||||
$iarr[0] = ''; // PHP5 compat hack
|
||||
}
|
||||
$fnarr = array_merge(array($sql), $iarr);
|
||||
$ret = call_user_func_array($fn, $fnarr);
|
||||
} else {
|
||||
$ret = $fn($sql);
|
||||
}
|
||||
} else {
|
||||
$fn = 'ibase_query';
|
||||
|
||||
if (is_array($iarr)) {
|
||||
if (sizeof($iarr) == 0)
|
||||
if (sizeof($iarr) == 0) {
|
||||
$iarr[0] = ''; // PHP5 compat hack
|
||||
$fnarr = array_merge( array($conn,$sql) , $iarr);
|
||||
$ret = call_user_func_array($fn,$fnarr);
|
||||
}
|
||||
else {
|
||||
}
|
||||
$fnarr = array_merge(array($conn, $sql), $iarr);
|
||||
$ret = call_user_func_array($fn, $fnarr);
|
||||
} else {
|
||||
$ret = $fn($conn, $sql);
|
||||
}
|
||||
}
|
||||
|
||||
// ibase_query() and ibase_execute() return number of affected rows
|
||||
// ADOConnection::_Execute() expects true for INSERT/UPDATE/DELETE
|
||||
if (is_numeric($ret)) {
|
||||
$ret = true;
|
||||
}
|
||||
|
||||
if ($docommit && $ret === true) {
|
||||
ibase_commit($this->_connectionID);
|
||||
}
|
||||
@@ -514,17 +520,24 @@ class ADODB_ibase extends ADOConnection {
|
||||
|
||||
$fld->has_default = true;
|
||||
$d = substr($rs->fields[2],strlen('default '));
|
||||
switch ($fld->type)
|
||||
{
|
||||
case 'smallint':
|
||||
case 'integer': $fld->default_value = (int) $d; break;
|
||||
case 'char':
|
||||
case 'blob':
|
||||
case 'text':
|
||||
case 'varchar': $fld->default_value = (string) substr($d,1,strlen($d)-2); break;
|
||||
case 'double':
|
||||
case 'float': $fld->default_value = (float) $d; break;
|
||||
default: $fld->default_value = $d; break;
|
||||
switch ($fld->type) {
|
||||
case 'smallint':
|
||||
case 'integer':
|
||||
$fld->default_value = (int)$d;
|
||||
break;
|
||||
case 'char':
|
||||
case 'blob':
|
||||
case 'text':
|
||||
case 'varchar':
|
||||
$fld->default_value = (string)substr($d, 1, strlen($d) - 2);
|
||||
break;
|
||||
case 'double':
|
||||
case 'float':
|
||||
$fld->default_value = (float)$d;
|
||||
break;
|
||||
default:
|
||||
$fld->default_value = $d;
|
||||
break;
|
||||
}
|
||||
// case 35:$tt = 'TIMESTAMP'; break;
|
||||
}
|
||||
@@ -558,9 +571,6 @@ class ADODB_ibase extends ADOConnection {
|
||||
return $blob;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// old blobdecode function
|
||||
// still used to auto-decode all blob's
|
||||
function _BlobDecode_old( $blob )
|
||||
@@ -625,34 +635,34 @@ class ADODB_ibase extends ADOConnection {
|
||||
*/
|
||||
function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
|
||||
{
|
||||
$blob_id = ibase_blob_create($this->_connectionID);
|
||||
$blob_id = ibase_blob_create($this->_connectionID);
|
||||
|
||||
// ibase_blob_add($blob_id, $val);
|
||||
// ibase_blob_add($blob_id, $val);
|
||||
|
||||
// replacement that solves the problem by which only the first modulus 64K /
|
||||
// of $val are stored at the blob field ////////////////////////////////////
|
||||
// Thx Abel Berenstein aberenstein#afip.gov.ar
|
||||
$len = strlen($val);
|
||||
$chunk_size = 32768;
|
||||
$tail_size = $len % $chunk_size;
|
||||
$n_chunks = ($len - $tail_size) / $chunk_size;
|
||||
// replacement that solves the problem by which only the first modulus 64K /
|
||||
// of $val are stored at the blob field ////////////////////////////////////
|
||||
// Thx Abel Berenstein aberenstein#afip.gov.ar
|
||||
$len = strlen($val);
|
||||
$chunk_size = 32768;
|
||||
$tail_size = $len % $chunk_size;
|
||||
$n_chunks = ($len - $tail_size) / $chunk_size;
|
||||
|
||||
for ($n = 0; $n < $n_chunks; $n++) {
|
||||
$start = $n * $chunk_size;
|
||||
$data = substr($val, $start, $chunk_size);
|
||||
ibase_blob_add($blob_id, $data);
|
||||
}
|
||||
for ($n = 0; $n < $n_chunks; $n++) {
|
||||
$start = $n * $chunk_size;
|
||||
$data = substr($val, $start, $chunk_size);
|
||||
ibase_blob_add($blob_id, $data);
|
||||
}
|
||||
|
||||
if ($tail_size) {
|
||||
$start = $n_chunks * $chunk_size;
|
||||
$data = substr($val, $start, $tail_size);
|
||||
ibase_blob_add($blob_id, $data);
|
||||
}
|
||||
// end replacement /////////////////////////////////////////////////////////
|
||||
if ($tail_size) {
|
||||
$start = $n_chunks * $chunk_size;
|
||||
$data = substr($val, $start, $tail_size);
|
||||
ibase_blob_add($blob_id, $data);
|
||||
}
|
||||
// end replacement /////////////////////////////////////////////////////////
|
||||
|
||||
$blob_id_str = ibase_blob_close($blob_id);
|
||||
$blob_id_str = ibase_blob_close($blob_id);
|
||||
|
||||
return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false;
|
||||
return $this->Execute("UPDATE $table SET $column=(?) WHERE $where", array($blob_id_str)) != false;
|
||||
|
||||
}
|
||||
|
||||
@@ -844,13 +854,12 @@ class ADORecordset_ibase extends ADORecordSet
|
||||
}
|
||||
|
||||
return $this->fields[$this->bind[strtoupper($colname)]];
|
||||
|
||||
}
|
||||
|
||||
|
||||
function _close()
|
||||
{
|
||||
return @ibase_free_result($this->_queryID);
|
||||
return @ibase_free_result($this->_queryID);
|
||||
}
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
@@ -860,35 +869,41 @@ class ADORecordset_ibase extends ADORecordSet
|
||||
$t = $fieldobj->type;
|
||||
$len = $fieldobj->max_length;
|
||||
}
|
||||
|
||||
|
||||
$t = strtoupper($t);
|
||||
|
||||
if (array_key_exists($t,$this->connection->customActualTypes))
|
||||
return $this->connection->customActualTypes[$t];
|
||||
|
||||
if (array_key_exists($t, $this->connection->customActualTypes)) {
|
||||
return $this->connection->customActualTypes[$t];
|
||||
}
|
||||
|
||||
switch ($t) {
|
||||
|
||||
case 'CHAR':
|
||||
return 'C';
|
||||
case 'CHAR':
|
||||
return 'C';
|
||||
|
||||
case 'TEXT':
|
||||
case 'VARCHAR':
|
||||
case 'VARYING':
|
||||
if ($len <= $this->blobSize) return 'C';
|
||||
return 'X';
|
||||
case 'BLOB':
|
||||
return 'B';
|
||||
case 'TEXT':
|
||||
case 'VARCHAR':
|
||||
case 'VARYING':
|
||||
if ($len <= $this->blobSize) {
|
||||
return 'C';
|
||||
}
|
||||
return 'X';
|
||||
case 'BLOB':
|
||||
return 'B';
|
||||
|
||||
case 'TIMESTAMP':
|
||||
case 'DATE': return 'D';
|
||||
case 'TIME': return 'T';
|
||||
//case 'T': return 'T';
|
||||
case 'TIMESTAMP':
|
||||
case 'DATE':
|
||||
return 'D';
|
||||
case 'TIME':
|
||||
return 'T';
|
||||
//case 'T': return 'T';
|
||||
|
||||
//case 'L': return 'L';
|
||||
case 'INT':
|
||||
case 'SHORT':
|
||||
case 'INTEGER': return 'I';
|
||||
default: return ADODB_DEFAULT_METATYPE;
|
||||
//case 'L': return 'L';
|
||||
case 'INT':
|
||||
case 'SHORT':
|
||||
case 'INTEGER':
|
||||
return 'I';
|
||||
default:
|
||||
return ADODB_DEFAULT_METATYPE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ class ADODB_mssqlnative extends ADOConnection {
|
||||
|
||||
$arrServerInfo = sqlsrv_server_info($this->_connectionID);
|
||||
$ADODB_FETCH_MODE = $savem;
|
||||
|
||||
|
||||
$arr = array();
|
||||
$arr['description'] = $arrServerInfo['SQLServerName'].' connected to '.$arrServerInfo['CurrentDatabase'];
|
||||
$arr['version'] = $arrServerInfo['SQLServerVersion'];//ADOConnection::_findvers($arr['description']);
|
||||
@@ -184,8 +184,10 @@ class ADODB_mssqlnative extends ADOConnection {
|
||||
|
||||
function _affectedrows()
|
||||
{
|
||||
if ($this->_queryID)
|
||||
return sqlsrv_rows_affected($this->_queryID);
|
||||
if ($this->_queryID && is_resource($this->_queryID)) {
|
||||
return sqlsrv_rows_affected($this->_queryID);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function GenID($seq='adodbseq',$start=1) {
|
||||
@@ -645,13 +647,6 @@ class ADODB_mssqlnative extends ADOConnection {
|
||||
$rez = sqlsrv_query($this->_connectionID, $sql);
|
||||
}
|
||||
|
||||
if ($this->debug) {
|
||||
ADOConnection::outp("<hr>running query: " . var_export($sql, true)
|
||||
. "<hr>input array: " . var_export($inputarr, true)
|
||||
. "<hr>result: " . var_export($rez, true)
|
||||
);
|
||||
}
|
||||
|
||||
$this->lastInsID = false;
|
||||
if (!$rez) {
|
||||
$rez = false;
|
||||
@@ -661,23 +656,27 @@ class ADODB_mssqlnative extends ADOConnection {
|
||||
// e.g. if triggers are involved (see #41)
|
||||
while (sqlsrv_next_result($rez)) {
|
||||
sqlsrv_fetch($rez);
|
||||
$this->lastInsID = sqlsrv_get_field($rez, 0, SQLSRV_PHPTYPE_INT);
|
||||
$this->lastInsID = sqlsrv_get_field($rez, 0);
|
||||
}
|
||||
}
|
||||
return $rez;
|
||||
}
|
||||
|
||||
// returns true or false
|
||||
/**
|
||||
* Rolls back pending transactions and closes the connection.
|
||||
*
|
||||
* @return bool True, unless the connection id is invalid
|
||||
*/
|
||||
function _close()
|
||||
{
|
||||
if ($this->transCnt) {
|
||||
$this->RollbackTrans();
|
||||
}
|
||||
if($this->_connectionID) {
|
||||
$rez = sqlsrv_close($this->_connectionID);
|
||||
if ($this->_connectionID) {
|
||||
return sqlsrv_close($this->_connectionID);
|
||||
}
|
||||
$this->_connectionID = false;
|
||||
return $rez;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1119,6 +1119,10 @@ class ADODB_mysqli extends ADOConnection {
|
||||
if (!is_array($inputarr)) {
|
||||
$inputarr = array($inputarr);
|
||||
}
|
||||
else {
|
||||
//remove alphanumeric placeholders
|
||||
$inputarr = array_values($inputarr);
|
||||
}
|
||||
|
||||
if (!is_array($sql)) {
|
||||
// Check if we are bulkbinding. If so, $inputarr is a 2d array,
|
||||
@@ -1307,6 +1311,10 @@ class ADODB_mysqli extends ADOConnection {
|
||||
|
||||
$ret = mysqli_stmt_execute($stmt);
|
||||
|
||||
// Store error code and message
|
||||
$this->_errorCode = $stmt->errno;
|
||||
$this->_errorMsg = $stmt->error;
|
||||
|
||||
/*
|
||||
* Did we throw an error?
|
||||
*/
|
||||
@@ -1332,6 +1340,10 @@ class ADODB_mysqli extends ADOConnection {
|
||||
*/
|
||||
$this->usePreparedStatement = false;
|
||||
$this->useLastInsertStatement = false;
|
||||
|
||||
// Reset error code and message
|
||||
$this->_errorCode = 0;
|
||||
$this->_errorMsg = '';
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1373,10 +1385,13 @@ class ADODB_mysqli extends ADOConnection {
|
||||
*/
|
||||
function ErrorMsg()
|
||||
{
|
||||
if (empty($this->_connectionID))
|
||||
$this->_errorMsg = @mysqli_connect_error();
|
||||
else
|
||||
$this->_errorMsg = @mysqli_error($this->_connectionID);
|
||||
if (!$this->_errorMsg) {
|
||||
if (empty($this->_connectionID)) {
|
||||
$this->_errorMsg = mysqli_connect_error();
|
||||
} else {
|
||||
$this->_errorMsg = $this->_connectionID->error ?? $this->_connectionID->connect_error;
|
||||
}
|
||||
}
|
||||
return $this->_errorMsg;
|
||||
}
|
||||
|
||||
@@ -1387,10 +1402,14 @@ class ADODB_mysqli extends ADOConnection {
|
||||
*/
|
||||
function ErrorNo()
|
||||
{
|
||||
if (empty($this->_connectionID))
|
||||
return @mysqli_connect_errno();
|
||||
else
|
||||
return @mysqli_errno($this->_connectionID);
|
||||
if (!$this->_errorCode) {
|
||||
if (empty($this->_connectionID)) {
|
||||
$this->_errorCode = mysqli_connect_errno();
|
||||
} else {
|
||||
$this->_errorCode = $this->_connectionID->errno ?? $this->_connectionID->connect_errno;
|
||||
}
|
||||
}
|
||||
return $this->_errorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -85,21 +85,21 @@ class ADODB_oci8po extends ADODB_oci8 {
|
||||
}
|
||||
return ADODB_oci8::_query($sql,$inputarr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replaces compatibility bind markers with oracle ones and returns a
|
||||
* valid sql statement
|
||||
*
|
||||
* This replaces a regexp based section of code that has been subject
|
||||
* to numerous tweaks, as more extreme test cases have appeared. This
|
||||
* is now done this like this to help maintainability and avoid the
|
||||
* is now done this like this to help maintainability and avoid the
|
||||
* need to rely on regexp experienced maintainers
|
||||
*
|
||||
* @param string $sql The sql statement
|
||||
* @param string[] $inputarr The bind array
|
||||
*
|
||||
* @return string The modified statement
|
||||
*/
|
||||
*/
|
||||
private function extractBinds($sql,$inputarr)
|
||||
{
|
||||
$inString = false;
|
||||
@@ -107,14 +107,13 @@ class ADODB_oci8po extends ADODB_oci8 {
|
||||
$sqlLength = strlen($sql) - 1;
|
||||
$newSql = '';
|
||||
$bindCount = 0;
|
||||
|
||||
|
||||
/*
|
||||
* inputarr is the passed in bind list, which is associative, but
|
||||
* we only want the keys here
|
||||
*/
|
||||
$inputKeys = array_keys($inputarr);
|
||||
|
||||
|
||||
|
||||
for ($i=0;$i<=$sqlLength;$i++)
|
||||
{
|
||||
/*
|
||||
@@ -137,7 +136,7 @@ class ADODB_oci8po extends ADODB_oci8 {
|
||||
* We found the end of the string
|
||||
*/
|
||||
$inString = false;
|
||||
|
||||
|
||||
if ($escaped == 2)
|
||||
$escaped = 0;
|
||||
|
||||
@@ -151,7 +150,7 @@ class ADODB_oci8po extends ADODB_oci8 {
|
||||
* Add the current character the pile
|
||||
*/
|
||||
$newSql .= $c;
|
||||
|
||||
|
||||
if ($escaped == 1)
|
||||
/*
|
||||
* We have just found an escape character, make sure we ignore the
|
||||
@@ -159,9 +158,9 @@ class ADODB_oci8po extends ADODB_oci8 {
|
||||
*/
|
||||
$escaped = 2;
|
||||
}
|
||||
|
||||
|
||||
return $newSql;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,14 +191,14 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
|
||||
{
|
||||
$fld = new ADOFieldObject;
|
||||
$fieldOffset += 1;
|
||||
$fld->name = OCIcolumnname($this->_queryID, $fieldOffset);
|
||||
$fld->name = oci_field_name($this->_queryID, $fieldOffset);
|
||||
if (ADODB_ASSOC_CASE == ADODB_ASSOC_CASE_LOWER) {
|
||||
$fld->name = strtolower($fld->name);
|
||||
}
|
||||
$fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
|
||||
$fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
|
||||
$fld->type = oci_field_type($this->_queryID, $fieldOffset);
|
||||
$fld->max_length = oci_field_size($this->_queryID, $fieldOffset);
|
||||
if ($fld->type == 'NUMBER') {
|
||||
$sc = OCIColumnScale($this->_queryID, $fieldOffset);
|
||||
$sc = oci_field_scale($this->_queryID, $fieldOffset);
|
||||
if ($sc == 0) {
|
||||
$fld->type = 'INT';
|
||||
}
|
||||
@@ -231,7 +230,6 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */
|
||||
function GetArrayLimit($nrows,$offset=-1)
|
||||
{
|
||||
if ($offset <= 0) {
|
||||
@@ -239,7 +237,7 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
|
||||
return $arr;
|
||||
}
|
||||
for ($i=1; $i < $offset; $i++)
|
||||
if (!@OCIFetch($this->_queryID)) {
|
||||
if (!@oci_fetch($this->_queryID)) {
|
||||
$arr = array();
|
||||
return $arr;
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ class ADODB_pdo extends ADOConnection {
|
||||
function Concat()
|
||||
{
|
||||
$args = func_get_args();
|
||||
if(method_exists($this->_driver, 'Concat')) {
|
||||
if($this->_driver instanceof ADODB_pdo && method_exists($this->_driver, 'Concat')) {
|
||||
return call_user_func_array(array($this->_driver, 'Concat'), $args);
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ class ADODB_pdo extends ADOConnection {
|
||||
public function param($name,$type='C') {
|
||||
|
||||
$args = func_get_args();
|
||||
if(method_exists($this->_driver, 'param')) {
|
||||
if($this->_driver instanceof ADODB_pdo && method_exists($this->_driver, 'param')) {
|
||||
// Return the driver specific entry, that mimics the native driver
|
||||
return call_user_func_array(array($this->_driver, 'param'), $args);
|
||||
}
|
||||
@@ -441,14 +441,14 @@ class ADODB_pdo extends ADOConnection {
|
||||
*/
|
||||
function SetAutoCommit($auto_commit)
|
||||
{
|
||||
if(method_exists($this->_driver, 'SetAutoCommit')) {
|
||||
if($this->_driver instanceof ADODB_pdo && method_exists($this->_driver, 'SetAutoCommit')) {
|
||||
$this->_driver->SetAutoCommit($auto_commit);
|
||||
}
|
||||
}
|
||||
|
||||
function SetTransactionMode($transaction_mode)
|
||||
{
|
||||
if(method_exists($this->_driver, 'SetTransactionMode')) {
|
||||
if($this->_driver instanceof ADODB_pdo && method_exists($this->_driver, 'SetTransactionMode')) {
|
||||
return $this->_driver->SetTransactionMode($transaction_mode);
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ class ADODB_pdo extends ADOConnection {
|
||||
|
||||
function beginTrans()
|
||||
{
|
||||
if(method_exists($this->_driver, 'beginTrans')) {
|
||||
if($this->_driver instanceof ADODB_pdo && method_exists($this->_driver, 'beginTrans')) {
|
||||
return $this->_driver->beginTrans();
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ class ADODB_pdo extends ADOConnection {
|
||||
function commitTrans($ok=true)
|
||||
{
|
||||
|
||||
if(method_exists($this->_driver, 'commitTrans')) {
|
||||
if($this->_driver instanceof ADODB_pdo && method_exists($this->_driver, 'commitTrans')) {
|
||||
return $this->_driver->commitTrans($ok);
|
||||
}
|
||||
|
||||
@@ -502,7 +502,7 @@ class ADODB_pdo extends ADOConnection {
|
||||
|
||||
function RollbackTrans()
|
||||
{
|
||||
if(method_exists($this->_driver, 'RollbackTrans')) {
|
||||
if($this->_driver instanceof ADODB_pdo && method_exists($this->_driver, 'RollbackTrans')) {
|
||||
return $this->_driver->RollbackTrans();
|
||||
}
|
||||
|
||||
@@ -544,7 +544,7 @@ class ADODB_pdo extends ADOConnection {
|
||||
|
||||
public function createSequence($seqname='adodbseq',$startID=1)
|
||||
{
|
||||
if(method_exists($this->_driver, 'createSequence')) {
|
||||
if($this->_driver instanceof ADODB_pdo && method_exists($this->_driver, 'createSequence')) {
|
||||
return $this->_driver->createSequence($seqname, $startID);
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ class ADODB_pdo extends ADOConnection {
|
||||
|
||||
function DropSequence($seqname='adodbseq')
|
||||
{
|
||||
if(method_exists($this->_driver, 'DropSequence')) {
|
||||
if($this->_driver instanceof ADODB_pdo && method_exists($this->_driver, 'DropSequence')) {
|
||||
return $this->_driver->DropSequence($seqname);
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ class ADODB_pdo extends ADOConnection {
|
||||
|
||||
function GenID($seqname='adodbseq',$startID=1)
|
||||
{
|
||||
if(method_exists($this->_driver, 'GenID')) {
|
||||
if($this->_driver instanceof ADODB_pdo && method_exists($this->_driver, 'GenID')) {
|
||||
return $this->_driver->GenID($seqname, $startID);
|
||||
}
|
||||
|
||||
|
||||
@@ -1075,7 +1075,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
|
||||
|
||||
function _close()
|
||||
{
|
||||
if ($this->_queryID === false) {
|
||||
if ($this->_queryID === false || $this->_queryID == self::DUMMY_QUERY_ID) {
|
||||
return true;
|
||||
}
|
||||
return pg_free_result($this->_queryID);
|
||||
|
||||
@@ -139,11 +139,14 @@ GLOBAL $gSQLMaxRows,$gSQLBlockRows,$ADODB_ROUND;
|
||||
*/
|
||||
|
||||
default:
|
||||
if ($htmlspecialchars) $v = htmlspecialchars(trim($v));
|
||||
$v = trim($v);
|
||||
if (strlen($v) == 0) $v = ' ';
|
||||
$s .= " <TD>". str_replace("\n",'<br>',stripslashes($v)) ."</TD>\n";
|
||||
|
||||
if ($v) {
|
||||
$v = htmlspecialchars(stripslashes(trim($v)));
|
||||
} elseif ($v === null) {
|
||||
$v = '(NULL)';
|
||||
} else {
|
||||
$v = ' ';
|
||||
}
|
||||
$s .= " <TD>" . str_replace("\n", '<br>', $v) . "</TD>\n";
|
||||
}
|
||||
} // for
|
||||
$s .= "</TR>\n\n";
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<location>adodb</location>
|
||||
<name>AdoDB</name>
|
||||
<description>Database abstraction library for MySQL, PostgreSQL, MSSQL, Oracle, Interbase, Foxpro, Access, ADO, Sybase, DB2 and ODBC.</description>
|
||||
<version>5.22.2</version>
|
||||
<version>5.22.4</version>
|
||||
<license>BSD/LGPL</license>
|
||||
<licenseversion>3-Clause/2.1+</licenseversion>
|
||||
<repository>https://github.com/ADOdb/ADOdb</repository>
|
||||
|
||||
Reference in New Issue
Block a user