MDL-79662 libraries: upgrade to version 5.22.7 of ADOdb.

This commit is contained in:
Paul Holden 2023-12-18 20:01:56 +00:00
parent 513f3b02c7
commit 827a00af52
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164
39 changed files with 272 additions and 186 deletions

View File

@ -76,10 +76,10 @@ $ADODB_INCLUDED_CSV = 1;
$savefetch = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode; $savefetch = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode;
$class = $rs->connection->arrayClass; $class = $rs->connection->arrayClass;
/** @var ADORecordSet $rs2 */
$rs2 = new $class(ADORecordSet::DUMMY_QUERY_ID); $rs2 = new $class(ADORecordSet::DUMMY_QUERY_ID);
$rs2->timeCreated = $rs->timeCreated; # memcache fix $rs2->timeCreated = $rs->timeCreated; # memcache fix
$rs2->sql = $rs->sql; $rs2->sql = $rs->sql;
$rs2->oldProvider = $rs->dataProvider;
$rs2->InitArrayFields($rows,$flds); $rs2->InitArrayFields($rows,$flds);
$rs2->fetchMode = $savefetch; $rs2->fetchMode = $savefetch;
return $line.serialize($rs2); return $line.serialize($rs2);

View File

@ -37,7 +37,14 @@ if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_H
*/ */
function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection) function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection)
{ {
if (error_reporting() == 0) return; // obey @ protocol // Do not throw if errors are suppressed by @ operator
// error_reporting() value for suppressed errors changed in PHP 8.0.0
$suppressed = version_compare(PHP_VERSION, '8.0.0', '<')
? 0
: E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE;
if (error_reporting() == $suppressed) {
return;
}
switch($fn) { switch($fn) {
case 'EXECUTE': case 'EXECUTE':
$sql = $p1; $sql = $p1;

View File

@ -52,7 +52,15 @@ function ADODB_Error_PEAR($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false)
{ {
global $ADODB_Last_PEAR_Error; global $ADODB_Last_PEAR_Error;
if (error_reporting() == 0) return; // obey @ protocol // Do not throw if errors are suppressed by @ operator
// error_reporting() value for suppressed errors changed in PHP 8.0.0
$suppressed = version_compare(PHP_VERSION, '8.0.0', '<')
? 0
: E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE;
if (error_reporting() == $suppressed) {
return;
}
switch($fn) { switch($fn) {
case 'EXECUTE': case 'EXECUTE':
$sql = $p1; $sql = $p1;

View File

@ -81,10 +81,18 @@ var $database = '';
function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection) function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
{ {
global $ADODB_EXCEPTION; global $ADODB_EXCEPTION;
// Do not throw if errors are suppressed by @ operator
// error_reporting() value for suppressed errors changed in PHP 8.0.0
$suppressed = version_compare(PHP_VERSION, '8.0.0', '<')
? 0
: E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE;
if (error_reporting() == $suppressed) {
return;
}
$errfn = is_string($ADODB_EXCEPTION) ? $ADODB_EXCEPTION : 'ADODB_EXCEPTION';
if (error_reporting() == 0) return; // obey @ protocol
if (is_string($ADODB_EXCEPTION)) $errfn = $ADODB_EXCEPTION;
else $errfn = 'ADODB_EXCEPTION';
throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection); throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection);
} }

View File

@ -508,32 +508,38 @@ function _adodb_getcount($zthis, $sql,$inputarr=false,$secs2cache=0)
return $qryRecs; return $qryRecs;
} }
/* /**
Code originally from "Cornel G" <conyg@fx.ro> * Execute query with pagination including record count.
*
This code might not work with SQL that has UNION in it * This code might not work with SQL that has UNION in it.
* Also if you are using cachePageExecute(), there is a strong possibility that
Also if you are using CachePageExecute(), there is a strong possibility that * data will get out of sync. cachePageExecute() should only be used with
data will get out of synch. use CachePageExecute() only with tables that * tables that rarely change.
rarely change. *
*/ * @param ADOConnection $zthis Connection
function _adodb_pageexecute_all_rows($zthis, $sql, $nrows, $page, * @param string $sql Query to execute
$inputarr=false, $secs2cache=0) * @param int $nrows Number of rows per page
* @param int $page Page number to retrieve (1-based)
* @param array $inputarr Array of bind variables
* @param int $secs2cache Time-to-live of the cache (in seconds), 0 to force query execution
*
* @return ADORecordSet|bool
*
* @author Cornel G <conyg@fx.ro>
*/
function _adodb_pageexecute_all_rows($zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0)
{ {
$atfirstpage = false; $atfirstpage = false;
$atlastpage = false; $atlastpage = false;
// If an invalid nrows is supplied, // If an invalid nrows is supplied, assume a default value of 10 rows per page
// we assume a default value of 10 rows per page
if (!isset($nrows) || $nrows <= 0) $nrows = 10; if (!isset($nrows) || $nrows <= 0) $nrows = 10;
$qryRecs = _adodb_getcount($zthis,$sql,$inputarr,$secs2cache); $qryRecs = _adodb_getcount($zthis,$sql,$inputarr,$secs2cache);
$lastpageno = (int) ceil($qryRecs / $nrows); $lastpageno = (int) ceil($qryRecs / $nrows);
$zthis->_maxRecordCount = $qryRecs;
// ***** Here we check whether $page is the last page or // Check whether $page is the last page or if we are trying to retrieve
// whether we are trying to retrieve // a page number greater than the last one.
// a page number greater than the last page number.
if ($page >= $lastpageno) { if ($page >= $lastpageno) {
$page = $lastpageno; $page = $lastpageno;
$atlastpage = true; $atlastpage = true;
@ -565,7 +571,25 @@ function _adodb_pageexecute_all_rows($zthis, $sql, $nrows, $page,
return $rsreturn; return $rsreturn;
} }
// Iván Oliva version /**
* Execute query with pagination without last page information.
*
* This code might not work with SQL that has UNION in it.
* Also if you are using cachePageExecute(), there is a strong possibility that
* data will get out of sync. cachePageExecute() should only be used with
* tables that rarely change.
*
* @param ADOConnection $zthis Connection
* @param string $sql Query to execute
* @param int $nrows Number of rows per page
* @param int $page Page number to retrieve (1-based)
* @param array $inputarr Array of bind variables
* @param int $secs2cache Time-to-live of the cache (in seconds), 0 to force query execution
*
* @return ADORecordSet|bool
*
* @author Iván Oliva
*/
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; $atfirstpage = false;

View File

@ -38,17 +38,17 @@ class ADOdbLoadBalancer
/** /**
* @var bool|array All connections to each database. * @var bool|array All connections to each database.
*/ */
protected $connections = false; protected $connections = [];
/** /**
* @var bool|array Just connections to the write capable database. * @var bool|array Just connections to the write capable database.
*/ */
protected $connections_write = false; protected $connections_write = [];
/** /**
* @var bool|array Just connections to the readonly database. * @var bool|array Just connections to the readonly database.
*/ */
protected $connections_readonly = false; protected $connections_readonly = [];
/** /**
* @var array Counts of all connections and their types. * @var array Counts of all connections and their types.
@ -73,12 +73,12 @@ class ADOdbLoadBalancer
/** /**
* @var bool Session variables that must be maintained across all connections, ie: SET TIME ZONE. * @var bool Session variables that must be maintained across all connections, ie: SET TIME ZONE.
*/ */
protected $session_variables = false; protected $session_variables = [];
/** /**
* @var bool Called immediately after connecting to any DB. * @var bool Called immediately after connecting to any DB.
*/ */
protected $user_defined_session_init_sql = false; protected $user_defined_session_init_sql = [];
/** /**
@ -403,7 +403,7 @@ class ADOdbLoadBalancer
*/ */
private function executeSessionVariables($adodb_obj = false) private function executeSessionVariables($adodb_obj = false)
{ {
if (is_array($this->session_variables)) { if (is_array($this->session_variables) && count($this->session_variables) > 0) {
$sql = ''; $sql = '';
foreach ($this->session_variables as $name => $value) { foreach ($this->session_variables as $name => $value) {
// $sql .= 'SET SESSION '. $name .' '. $value; // $sql .= 'SET SESSION '. $name .' '. $value;

View File

@ -1017,7 +1017,7 @@ Committed_AS: 348732 kB
* <code>ADODB_OPT_LOW</code> for CPU-less optimization * <code>ADODB_OPT_LOW</code> for CPU-less optimization
* Default is LOW <code>ADODB_OPT_LOW</code> * Default is LOW <code>ADODB_OPT_LOW</code>
* @author Markus Staab * @author Markus Staab
* @return Returns <code>true</code> on success and <code>false</code> on error * @return bool true on success, false on error
*/ */
function OptimizeTables() function OptimizeTables()
{ {
@ -1048,7 +1048,7 @@ Committed_AS: 348732 kB
* <code>ADODB_OPT_LOW</code> for CPU-less optimization * <code>ADODB_OPT_LOW</code> for CPU-less optimization
* Default is LOW <code>ADODB_OPT_LOW</code> * Default is LOW <code>ADODB_OPT_LOW</code>
* @author Markus Staab * @author Markus Staab
* @return Returns <code>true</code> on success and <code>false</code> on error * @return bool true on success, false on error
*/ */
function OptimizeTable( $table, $mode = ADODB_OPT_LOW) function OptimizeTable( $table, $mode = ADODB_OPT_LOW)
{ {
@ -1062,7 +1062,7 @@ Committed_AS: 348732 kB
* optimize each using <code>optmizeTable()</code> * optimize each using <code>optmizeTable()</code>
* *
* @author Markus Staab * @author Markus Staab
* @return Returns <code>true</code> on success and <code>false</code> on error * @return bool true on success, false on error
*/ */
function optimizeDatabase() function optimizeDatabase()
{ {

View File

@ -2,6 +2,8 @@
/** /**
* ADOdb Date Library. * ADOdb Date Library.
* *
* @deprecated 5.22.6 Use 64-bit PHP native functions instead.
*
* PHP native date functions use integer timestamps for computations. * PHP native date functions use integer timestamps for computations.
* Because of this, dates are restricted to the years 1901-2038 on Unix * Because of this, dates are restricted to the years 1901-2038 on Unix
* and 1970-2038 on Windows due to integer overflow for dates beyond * and 1970-2038 on Windows due to integer overflow for dates beyond

View File

@ -412,7 +412,7 @@ class dbTable extends dbObject {
* @param string $type ADODB datadict field type. * @param string $type ADODB datadict field type.
* @param string $size Field size * @param string $size Field size
* @param array $opts Field options array * @param array $opts Field options array
* @return array Field specifier array * @return void
*/ */
function addField( $name, $type, $size = NULL, $opts = NULL ) { function addField( $name, $type, $size = NULL, $opts = NULL ) {
$field_id = $this->FieldID( $name ); $field_id = $this->FieldID( $name );
@ -446,7 +446,7 @@ class dbTable extends dbObject {
* @param string $field Field name * @param string $field Field name
* @param string $opt ADOdb field option * @param string $opt ADOdb field option
* @param mixed $value Field option value * @param mixed $value Field option value
* @return array Field specifier array * @return void
*/ */
function addFieldOpt( $field, $opt, $value = NULL ) { function addFieldOpt( $field, $opt, $value = NULL ) {
if( !isset( $value ) ) { if( !isset( $value ) ) {

View File

@ -450,7 +450,7 @@ class dbTable extends dbObject {
* @param string $type ADODB datadict field type. * @param string $type ADODB datadict field type.
* @param string $size Field size * @param string $size Field size
* @param array $opts Field options array * @param array $opts Field options array
* @return array Field specifier array * @return void
*/ */
function addField( $name, $type, $size = NULL, $opts = NULL ) { function addField( $name, $type, $size = NULL, $opts = NULL ) {
$field_id = $this->fieldID( $name ); $field_id = $this->fieldID( $name );
@ -486,7 +486,7 @@ class dbTable extends dbObject {
* @param string $field Field name * @param string $field Field name
* @param string $opt ADOdb field option * @param string $opt ADOdb field option
* @param mixed $value Field option value * @param mixed $value Field option value
* @return array Field specifier array * @return void
*/ */
function addFieldOpt( $field, $opt, $value = NULL ) { function addFieldOpt( $field, $opt, $value = NULL ) {
if( $this->currentPlatform ) { if( $this->currentPlatform ) {
@ -766,7 +766,7 @@ class dbIndex extends dbObject {
* Adds a field to the index * Adds a field to the index
* *
* @param string $name Field name * @param string $name Field name
* @return string Field list * @return string[] Field list
*/ */
function addField( $name ) { function addField( $name ) {
$this->columns[$this->fieldID( $name )] = $name; $this->columns[$this->fieldID( $name )] = $name;
@ -779,7 +779,7 @@ class dbIndex extends dbObject {
* Adds options to the index * Adds options to the index
* *
* @param string $opt Comma-separated list of index options. * @param string $opt Comma-separated list of index options.
* @return string Option list * @return string[] Option list
*/ */
function addIndexOpt( $opt ) { function addIndexOpt( $opt ) {
$this->opts[] = $opt; $this->opts[] = $opt;
@ -929,10 +929,10 @@ class dbData extends dbObject {
} }
/** /**
* Adds options to the index * Adds data.
* *
* @param string $opt Comma-separated list of index options. * @param string $cdata Data to add
* @return string Option list * @return void
*/ */
function addData( $cdata ) { function addData( $cdata ) {
// check we're in a valid field // check we're in a valid field
@ -1782,7 +1782,7 @@ class adoSchema {
$sqlArray = $this->sqlArray; $sqlArray = $this->sqlArray;
} }
if( !isset( $sqlArray ) ) { if( !isset( $sqlArray ) ) {
return FALSE; return false;
} }
$fp = fopen( $filename, "w" ); $fp = fopen( $filename, "w" );

View File

@ -198,7 +198,7 @@ if (!defined('_ADODB_LAYER')) {
/** /**
* ADODB version as a string. * ADODB version as a string.
*/ */
$ADODB_vers = 'v5.22.5 2023-04-03'; $ADODB_vers = 'v5.22.7 2023-11-04';
/** /**
* Determines whether recordset->RecordCount() is used. * Determines whether recordset->RecordCount() is used.
@ -1466,7 +1466,7 @@ if (!defined('_ADODB_LAYER')) {
* @param array|bool $inputarr holds the input data to bind to. * @param array|bool $inputarr holds the input data to bind to.
* Null elements will be set to null. * Null elements will be set to null.
* *
* @return ADORecordSet|bool * @return ADORecordSet|false
*/ */
public function Execute($sql, $inputarr = false) { public function Execute($sql, $inputarr = false) {
if ($this->fnExecute) { if ($this->fnExecute) {
@ -1666,6 +1666,18 @@ if (!defined('_ADODB_LAYER')) {
return $rs; return $rs;
} }
/**
* Execute a query.
*
* @param string|array $sql Query to execute.
* @param array $inputarr An optional array of parameters.
*
* @return mixed|bool Query identifier or true if execution successful, false if failed.
*/
function _query($sql, $inputarr = false) {
return false;
}
function CreateSequence($seqname='adodbseq',$startID=1) { function CreateSequence($seqname='adodbseq',$startID=1) {
if (empty($this->_genSeqSQL)) { if (empty($this->_genSeqSQL)) {
return false; return false;
@ -3554,20 +3566,21 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
/** /**
* Will select the supplied $page number from a recordset, given that it is paginated in pages of * Execute query with pagination.
* $nrows rows per page. It also saves two boolean values saying if the given page is the first
* and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination.
* *
* See docs-adodb.htm#ex8 for an example of usage. * Will select the supplied $page number from a recordset, divided in
* NOTE: phpLens uses a different algorithm and does not use PageExecute(). * pages of $nrows rows each. It also saves two boolean values saying
* if the given page is the first and/or last one of the recordset.
* *
* @param string $sql * @param string $sql Query to execute
* @param int $nrows Number of rows per page to get * @param int $nrows Number of rows per page
* @param int $page Page number to get (1-based) * @param int $page Page number to retrieve (1-based)
* @param mixed[]|bool $inputarr Array of bind variables * @param array|bool $inputarr Array of bind variables
* @param int $secs2cache Private parameter only used by jlim * @param int $secs2cache Time-to-live of the cache (in seconds), 0 to force query execution
* *
* @return mixed the recordset ($rs->databaseType == 'array') * @return ADORecordSet|bool the recordset ($rs->databaseType == 'array')
*
* @author Iván Oliva
*/ */
function PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0) { function PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0) {
global $ADODB_INCLUDED_LIB; global $ADODB_INCLUDED_LIB;
@ -3743,7 +3756,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1
/** /**
* Internal placeholder for record objects. Used by ADORecordSet->FetchObj(). * Internal placeholder for record objects. Used by ADORecordSet->FetchObj().
*/ */
#[AllowDynamicProperties] #[\AllowDynamicProperties]
class ADOFetchObj { class ADOFetchObj {
}; };
@ -3983,11 +3996,20 @@ class ADORecordSet implements IteratorAggregate {
var $_obj; /** Used by FetchObj */ var $_obj; /** Used by FetchObj */
var $_names; /** Used by FetchObj */ var $_names; /** Used by FetchObj */
var $_currentPage = -1; /** Added by Iván Oliva to implement recordset pagination */ // Recordset pagination
var $_atFirstPage = false; /** Added by Iván Oliva to implement recordset pagination */ /** @var int Number of rows per page */
var $_atLastPage = false; /** Added by Iván Oliva to implement recordset pagination */ var $rowsPerPage;
/** @var int Current page number */
var $_currentPage = -1;
/** @var bool True if current page is the first page */
var $_atFirstPage = false;
/** @var bool True if current page is the last page */
var $_atLastPage = false;
/** @var int Last page number */
var $_lastPageNo = -1; var $_lastPageNo = -1;
/** @var int Total number of rows in recordset */
var $_maxRecordCount = 0; var $_maxRecordCount = 0;
var $datetime = false; var $datetime = false;
public $customActualTypes; public $customActualTypes;

View File

@ -208,10 +208,6 @@ class ADODB_ado extends ADOConnection {
return empty($arr) ? $false : $arr; return empty($arr) ? $false : $arr;
} }
/* returns queryID or false */
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
@ -504,7 +500,7 @@ class ADORecordSet_ado extends ADORecordSet {
$t = $fieldobj->type; $t = $fieldobj->type;
$len = $fieldobj->max_length; $len = $fieldobj->max_length;
} }
if (array_key_exists($t,$this->connection->customActualTypes)) if (array_key_exists($t,$this->connection->customActualTypes))
return $this->connection->customActualTypes[$t]; return $this->connection->customActualTypes[$t];

View File

@ -233,7 +233,6 @@ class ADODB_ado extends ADOConnection {
return $arr; return $arr;
} }
/* returns queryID or false */
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
try { // In PHP5, all COM errors are exceptions, so to maintain old behaviour... try { // In PHP5, all COM errors are exceptions, so to maintain old behaviour...
@ -545,13 +544,13 @@ class ADORecordSet_ado extends ADORecordSet {
$t = $fieldobj->type; $t = $fieldobj->type;
$len = $fieldobj->max_length; $len = $fieldobj->max_length;
} }
$t = strtoupper($t); $t = strtoupper($t);
if (array_key_exists($t,$this->connection->customActualTypes)) if (array_key_exists($t,$this->connection->customActualTypes))
return $this->connection->customActualTypes[$t]; return $this->connection->customActualTypes[$t];
if (!is_numeric($t)) if (!is_numeric($t))
return $t; return $t;
switch ($t) { switch ($t) {

View File

@ -564,7 +564,6 @@ class ADODB_ads extends ADOConnection
return array($sql, $stmt, false); return array($sql, $stmt, false);
} }
/* returns queryID or false */
function _query($sql, $inputarr = false) function _query($sql, $inputarr = false)
{ {
$last_php_error = $this->resetLastError(); $last_php_error = $this->resetLastError();

View File

@ -199,7 +199,7 @@ class ADODB_csv extends ADOConnection {
} }
} // class } // class
class ADORecordset_csv extends ADORecordset { class ADORecordset_csv extends ADORecordSet {
function _close() function _close()
{ {

View File

@ -1568,7 +1568,7 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/db2/htm/db2
* *
* @return mixed either the queryID or false * @return mixed either the queryID or false
*/ */
function _query(&$sql,$inputarr=false) function _query($sql, $inputarr = false)
{ {
$db2Options = array(); $db2Options = array();
/* /*

View File

@ -134,7 +134,6 @@ class ADODB_fbsql extends ADOConnection {
} }
// returns queryID or false
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
return fbsql_query("$sql;",$this->_connectionID); return fbsql_query("$sql;",$this->_connectionID);

View File

@ -483,14 +483,14 @@ class ADODB_firebird extends ADOConnection {
} }
/** /**
* Return the query id. * Execute a query.
* *
* @param string|array $sql * @param string|array $sql Query to execute.
* @param array $iarr * @param array $inputarr An optional array of parameters.
* *
* @return bool|object * @return object|bool Query identifier or true if execution successful, false if failed.
*/ */
function _query($sql, $iarr = false) function _query($sql, $inputarr = false)
{ {
if (!$this->isConnected()) { if (!$this->isConnected()) {
return false; return false;
@ -512,8 +512,8 @@ class ADODB_firebird extends ADOConnection {
$fn = 'fbird_query'; $fn = 'fbird_query';
$args = [$conn, $sql]; $args = [$conn, $sql];
} }
if (is_array($iarr)) { if (is_array($inputarr)) {
$args = array_merge($args, $iarr); $args = array_merge($args, $inputarr);
} }
$ret = call_user_func_array($fn, $args); $ret = call_user_func_array($fn, $args);

View File

@ -256,7 +256,7 @@ class ADODB_ibase extends ADOConnection {
// See http://community.borland.com/article/0,1410,25844,00.html // See http://community.borland.com/article/0,1410,25844,00.html
function RowLock($tables,$where,$col=false) function rowLock($table, $where, $col = false)
{ {
if ($this->autoCommit) { if ($this->autoCommit) {
$this->BeginTrans(); $this->BeginTrans();
@ -332,7 +332,7 @@ class ADODB_ibase extends ADOConnection {
// returns query ID if successful, otherwise false // returns query ID if successful, otherwise false
// there have been reports of problems with nested queries - the code is probably not re-entrant? // there have been reports of problems with nested queries - the code is probably not re-entrant?
function _query($sql,$iarr=false) function _query($sql, $inputarr = false)
{ {
if (!$this->autoCommit && $this->_transactionID) { if (!$this->autoCommit && $this->_transactionID) {
$conn = $this->_transactionID; $conn = $this->_transactionID;
@ -344,11 +344,11 @@ class ADODB_ibase extends ADOConnection {
if (is_array($sql)) { if (is_array($sql)) {
$fn = 'ibase_execute'; $fn = 'ibase_execute';
$sql = $sql[1]; $sql = $sql[1];
if (is_array($iarr)) { if (is_array($inputarr)) {
if (!isset($iarr[0])) { if (!isset($inputarr[0])) {
$iarr[0] = ''; // PHP5 compat hack $inputarr[0] = ''; // PHP5 compat hack
} }
$fnarr = array_merge(array($sql), $iarr); $fnarr = array_merge(array($sql), $inputarr);
$ret = call_user_func_array($fn, $fnarr); $ret = call_user_func_array($fn, $fnarr);
} else { } else {
$ret = $fn($sql); $ret = $fn($sql);
@ -356,11 +356,11 @@ class ADODB_ibase extends ADOConnection {
} else { } else {
$fn = 'ibase_query'; $fn = 'ibase_query';
if (is_array($iarr)) { if (is_array($inputarr)) {
if (sizeof($iarr) == 0) { if (sizeof($inputarr) == 0) {
$iarr[0] = ''; // PHP5 compat hack $inputarr[0] = ''; // PHP5 compat hack
} }
$fnarr = array_merge(array($conn, $sql), $iarr); $fnarr = array_merge(array($conn, $sql), $inputarr);
$ret = call_user_func_array($fn, $fnarr); $ret = call_user_func_array($fn, $fnarr);
} else { } else {
$ret = $fn($conn, $sql); $ret = $fn($conn, $sql);
@ -734,7 +734,7 @@ class ADODB_ibase extends ADOConnection {
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordset_ibase extends ADORecordSet class ADORecordSet_ibase extends ADORecordSet
{ {
var $databaseType = "ibase"; var $databaseType = "ibase";

View File

@ -334,7 +334,6 @@ class ADODB_informix72 extends ADOConnection {
else return array($sql,$stmt); else return array($sql,$stmt);
} }
*/ */
// returns query ID if successful, otherwise false
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
global $ADODB_COUNTRECS; global $ADODB_COUNTRECS;

View File

@ -157,7 +157,6 @@ class ADODB_ldap extends ADOConnection {
} }
} }
/* returns _queryID or false */
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
$rs = @ldap_search( $this->_connectionID, $this->database, $sql ); $rs = @ldap_search( $this->_connectionID, $this->database, $sql );

View File

@ -725,7 +725,6 @@ order by constraint_name, referenced_table_name, keyno";
return $this->Execute($sql) != false; return $this->Execute($sql) != false;
} }
// returns query ID if successful, otherwise false
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
$this->_errorMsg = false; $this->_errorMsg = false;

View File

@ -167,6 +167,14 @@ class ADODB_mysqli extends ADOConnection {
if(!extension_loaded("mysqli")) { if(!extension_loaded("mysqli")) {
return null; return null;
} }
// Check for a function that only exists in mysqlnd
if (!function_exists('mysqli_stmt_get_result')) {
// @TODO This will be treated as if the mysqli extension were not available
// This could be misleading, so we output an additional error message.
// We should probably throw a specific exception instead.
$this->outp("MySQL Native Driver (msqlnd) required");
return null;
}
$this->_connectionID = @mysqli_init(); $this->_connectionID = @mysqli_init();
if (is_null($this->_connectionID)) { if (is_null($this->_connectionID)) {
@ -1091,16 +1099,6 @@ class ADODB_mysqli extends ADOConnection {
return array($sql,$stmt); return array($sql,$stmt);
} }
/**
* Execute SQL
*
* @param string $sql SQL statement to execute, or possibly an array
* holding prepared statement ($sql[0] will hold sql text)
* @param array|bool $inputarr holds the input data to bind to.
* Null elements will be set to null.
*
* @return ADORecordSet|bool
*/
public function execute($sql, $inputarr = false) public function execute($sql, $inputarr = false)
{ {
if ($this->fnExecute) { if ($this->fnExecute) {
@ -1146,8 +1144,10 @@ class ADODB_mysqli extends ADOConnection {
} }
$bulkTypeArray[] = $typeArray; $bulkTypeArray[] = $typeArray;
} }
$currentBulkBind = $this->bulkBind;
$this->bulkBind = false; $this->bulkBind = false;
$ret = $this->_execute($sql, $bulkTypeArray); $ret = $this->_execute($sql, $bulkTypeArray);
$this->bulkBind = $currentBulkBind;
} else { } else {
$typeArray = $this->getBindParamWithType($inputarr); $typeArray = $this->getBindParamWithType($inputarr);
$ret = $this->_execute($sql, $typeArray); $ret = $this->_execute($sql, $typeArray);
@ -1189,14 +1189,14 @@ class ADODB_mysqli extends ADOConnection {
} }
/** /**
* Return the query id. * Execute a query.
* *
* @param string|array $sql * @param string|array $sql Query to execute.
* @param array $inputarr * @param array $inputarr An optional array of parameters.
* *
* @return bool|mysqli_result * @return mysqli_result|bool
*/ */
function _query($sql, $inputarr) function _query($sql, $inputarr = false)
{ {
global $ADODB_COUNTRECS; global $ADODB_COUNTRECS;
// Move to the next recordset, or return false if there is none. In a stored proc // Move to the next recordset, or return false if there is none. In a stored proc
@ -1466,6 +1466,9 @@ class ADODB_mysqli extends ADOConnection {
return $this->charSet ?: false; return $this->charSet ?: false;
} }
/**
* @deprecated 5.21.0 Use {@see setConnectionParameter()} instead
*/
function setCharSet($charset) function setCharSet($charset)
{ {
if (!$this->_connectionID || !method_exists($this->_connectionID,'set_charset')) { if (!$this->_connectionID || !method_exists($this->_connectionID,'set_charset')) {

View File

@ -92,7 +92,7 @@ END;
var $random = "abs(mod(DBMS_RANDOM.RANDOM,10000001)/10000000)"; var $random = "abs(mod(DBMS_RANDOM.RANDOM,10000001)/10000000)";
var $noNullStrings = false; var $noNullStrings = false;
var $connectSID = false; var $connectSID = false;
var $_bind = false; var $_bind = array();
var $_nestedSQL = true; var $_nestedSQL = true;
var $_getarray = false; // currently not working var $_getarray = false; // currently not working
var $leftOuter = ''; // oracle wierdness, $col = $value (+) for LEFT OUTER, $col (+)= $value for RIGHT OUTER var $leftOuter = ''; // oracle wierdness, $col = $value (+) for LEFT OUTER, $col (+)= $value for RIGHT OUTER
@ -781,6 +781,11 @@ END;
$hint = ''; $hint = '';
} }
// If non-bound statement, $inputarr is false
if (!$inputarr) {
$inputarr = array();
}
if ($offset == -1 || ($offset < $this->selectOffsetAlg1 && 0 < $nrows && $nrows < 1000)) { if ($offset == -1 || ($offset < $this->selectOffsetAlg1 && 0 < $nrows && $nrows < 1000)) {
if ($nrows > 0) { if ($nrows > 0) {
if ($offset > 0) { if ($offset > 0) {
@ -788,10 +793,6 @@ END;
} }
$sql = "select * from (".$sql.") where rownum <= :adodb_offset"; $sql = "select * from (".$sql.") where rownum <= :adodb_offset";
// If non-bound statement, $inputarr is false
if (!$inputarr) {
$inputarr = array();
}
$inputarr['adodb_offset'] = $nrows; $inputarr['adodb_offset'] = $nrows;
$nrows = -1; $nrows = -1;
} }
@ -809,32 +810,31 @@ END;
} }
$stmt = $stmt_arr[1]; $stmt = $stmt_arr[1];
if (is_array($inputarr)) { foreach($inputarr as $k => $v) {
foreach($inputarr as $k => $v) { $i = 0;
$i=0; if ($this->databaseType == 'oci8po') {
if ($this->databaseType == 'oci8po') { $bv_name = ":" . $i++;
$bv_name = ":".$i++; } else {
$bv_name = ":" . $k;
}
if (is_array($v)) {
// suggested by g.giunta@libero.
if (sizeof($v) == 2) {
oci_bind_by_name($stmt, $bv_name, $inputarr[$k][0], $v[1]);
} else { } else {
$bv_name = ":".$k; oci_bind_by_name($stmt, $bv_name, $inputarr[$k][0], $v[1], $v[2]);
} }
if (is_array($v)) { } else {
// suggested by g.giunta@libero. $len = -1;
if (sizeof($v) == 2) { if ($v === ' ') {
oci_bind_by_name($stmt,$bv_name,$inputarr[$k][0],$v[1]); $len = 1;
} }
else { if (isset($bindarr)) {
oci_bind_by_name($stmt,$bv_name,$inputarr[$k][0],$v[1],$v[2]); // prepared sql, so no need to oci_bind_by_name again
} $bindarr[$k] = $v;
} else { } else {
$len = -1; // dynamic sql, so rebind every time
if ($v === ' ') { oci_bind_by_name($stmt, $bv_name, $inputarr[$k], $len);
$len = 1;
}
if (isset($bindarr)) { // is prepared sql, so no need to oci_bind_by_name again
$bindarr[$k] = $v;
} else { // dynamic sql, so rebind every time
oci_bind_by_name($stmt,$bv_name,$inputarr[$k],$len);
}
} }
} }
} }
@ -971,16 +971,6 @@ END;
return $rez; return $rez;
} }
/**
* Execute SQL
*
* @param string|array $sql SQL statement to execute, or possibly an array holding
* prepared statement ($sql[0] will hold sql text).
* @param array|false $inputarr holds the input data to bind to.
* Null elements will be set to null.
*
* @return ADORecordSet|false
*/
function Execute($sql,$inputarr=false) function Execute($sql,$inputarr=false)
{ {
if ($this->fnExecute) { if ($this->fnExecute) {
@ -1282,7 +1272,8 @@ END;
} }
/** /**
* returns query ID if successful, otherwise false * Execute a query.
*
* this version supports: * this version supports:
* *
* 1. $db->execute('select * from table'); * 1. $db->execute('select * from table');
@ -1295,6 +1286,11 @@ END;
* 4. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)'); * 4. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)');
* $db->bind($stmt,1); $db->bind($stmt,2); $db->bind($stmt,3); * $db->bind($stmt,1); $db->bind($stmt,2); $db->bind($stmt,3);
* $db->execute($stmt); * $db->execute($stmt);
*
* @param string|array $sql Query to execute.
* @param array $inputarr An optional array of parameters.
*
* @return mixed|bool Query identifier or true if execution successful, false if failed.
*/ */
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
@ -1583,6 +1579,9 @@ SELECT /*+ RULE */ distinct b.column_name
if ($this->noNullStrings && strlen($s) == 0) { if ($this->noNullStrings && strlen($s) == 0) {
$s = ' '; $s = ' ';
} }
else if (strlen($s) == 0) {
return "''";
}
if ($this->replaceQuote[0] == '\\'){ if ($this->replaceQuote[0] == '\\'){
$s = str_replace('\\','\\\\',$s); $s = str_replace('\\','\\\\',$s);
} }

View File

@ -70,7 +70,16 @@ class ADODB_oci8po extends ADODB_oci8 {
return ADOConnection::SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache); return ADOConnection::SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache);
} }
// emulate handling of parameters ? ?, replacing with :bind0 :bind1 /**
* Execute a query.
*
* Emulate handling of parameters ? ?, replacing with :bind0 :bind1
*
* @param string|array $sql Query to execute.
* @param array $inputarr An optional array of parameters.
*
* @return mixed|bool Query identifier or true if execution successful, false if failed.
*/
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
if (is_array($inputarr)) { if (is_array($inputarr)) {

View File

@ -26,7 +26,7 @@ if (!defined('ADODB_DIR')) die();
/* /*
* These constants are used to set define MetaColumns() method's behavior. * These constants are used to set define MetaColumns() method's behavior.
* - METACOLUMNS_RETURNS_ACTUAL makes the driver return the actual type, * - METACOLUMNS_RETURNS_ACTUAL makes the driver return the actual type,
* like all other drivers do (default) * like all other drivers do (default)
* - METACOLUMNS_RETURNS_META is provided for legacy compatibility (makes * - METACOLUMNS_RETURNS_META is provided for legacy compatibility (makes
* driver behave as it did prior to v5.21) * driver behave as it did prior to v5.21)
@ -35,7 +35,7 @@ if (!defined('ADODB_DIR')) die();
*/ */
DEFINE('METACOLUMNS_RETURNS_ACTUAL', 0); DEFINE('METACOLUMNS_RETURNS_ACTUAL', 0);
DEFINE('METACOLUMNS_RETURNS_META', 1); DEFINE('METACOLUMNS_RETURNS_META', 1);
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
@ -57,7 +57,7 @@ class ADODB_odbc extends ADOConnection {
var $_autocommit = true; var $_autocommit = true;
var $_lastAffectedRows = 0; var $_lastAffectedRows = 0;
var $uCaseTables = true; // for meta* functions, uppercase table names var $uCaseTables = true; // for meta* functions, uppercase table names
/* /*
* Tells the metaColumns feature whether to return actual or meta type * Tells the metaColumns feature whether to return actual or meta type
*/ */
@ -473,7 +473,7 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/od
$fld = new ADOFieldObject(); $fld = new ADOFieldObject();
$fld->name = $rs->fields[3]; $fld->name = $rs->fields[3];
if ($this->metaColumnsReturnType == METACOLUMNS_RETURNS_META) if ($this->metaColumnsReturnType == METACOLUMNS_RETURNS_META)
/* /*
* This is the broken, original value * This is the broken, original value
*/ */
$fld->type = $this->ODBCTypes($rs->fields[4]); $fld->type = $this->ODBCTypes($rs->fields[4]);
@ -518,7 +518,6 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/od
return array($sql,$stmt,false); return array($sql,$stmt,false);
} }
/* returns queryID or false */
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
$last_php_error = $this->resetLastError(); $last_php_error = $this->resetLastError();

View File

@ -181,7 +181,6 @@ class ADODB_oracle extends ADOConnection {
} }
// returns query ID if successful, otherwise false
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
// <G. Giunta 2003/03/03/> Reset error messages before executing // <G. Giunta 2003/03/03/> Reset error messages before executing

View File

@ -578,7 +578,6 @@ class ADODB_pdo extends ADOConnection {
} }
/* returns queryID or false */
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
$ok = false; $ok = false;

View File

@ -258,7 +258,9 @@ class ADODB_postgres64 extends ADOConnection{
if ($this->_connectionID) { if ($this->_connectionID) {
return "'" . pg_escape_string($this->_connectionID, $s) . "'"; return "'" . pg_escape_string($this->_connectionID, $s) . "'";
} else { } else {
return "'" . pg_escape_string($s) . "'"; // Fall back to emulated escaping when there is no database connection.
// Avoids errors when using setSessionVariables() in the load balancer.
return parent::qStr( $s );
} }
} }
@ -782,7 +784,6 @@ class ADODB_postgres64 extends ADOConnection{
} }
// returns queryID or false
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
$this->_pnum = 0; $this->_pnum = 0;

View File

@ -45,11 +45,23 @@ class ADODB_postgres8 extends ADODB_postgres7
* @return int last inserted ID for given table/column, or the most recently * @return int last inserted ID for given table/column, or the most recently
* returned one if $table or $column are empty * returned one if $table or $column are empty
*/ */
protected function _insertID($table = '', $column = '') protected function _insertID( $table = '', $column = '' )
{ {
return empty($table) || empty($column) global $ADODB_GETONE_EOF;
? $this->GetOne("SELECT lastval()")
: $this->GetOne("SELECT currval(pg_get_serial_sequence('$table', '$column'))"); $sql = empty($table) || empty($column)
? 'SELECT lastval()'
: "SELECT currval(pg_get_serial_sequence('$table', '$column'))";
// Squelch "ERROR: lastval is not yet defined in this session" (see #978)
$result = @$this->GetOne($sql);
if ($result === false || $result == $ADODB_GETONE_EOF) {
if ($this->debug) {
ADOConnection::outp(__FUNCTION__ . "() failed : " . $this->errorMsg());
}
return false;
}
return $result;
} }
} }

View File

@ -116,7 +116,7 @@ if (!defined('ADODB_SYBASE_SQLANYWHERE')){
$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
$conn->UpdateBlob('blobtable','blobcol',$blob,'id=1'); $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
*/ */
function UpdateBlob($table,$column,&$val,$where,$blobtype='BLOB') function updateBlob($table, $column, $val, $where, $blobtype = 'BLOB')
{ {
$blobVarName = 'hold_blob'; $blobVarName = 'hold_blob';
$this->create_blobvar($blobVarName); $this->create_blobvar($blobVarName);

View File

@ -211,7 +211,6 @@ class ADODB_sqlite extends ADOConnection {
return true; return true;
} }
// returns query ID if successful, otherwise false
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
$rez = sqlite_query($sql,$this->_connectionID); $rez = sqlite_query($sql,$this->_connectionID);

View File

@ -331,7 +331,6 @@ class ADODB_sqlite3 extends ADOConnection {
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename); return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
} }
// returns query ID if successful, otherwise false
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
$rez = $this->_connectionID->query($sql); $rez = $this->_connectionID->query($sql);

View File

@ -170,7 +170,6 @@ class ADODB_sybase extends ADOConnection {
return true; return true;
} }
// returns query ID if successful, otherwise false
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
global $ADODB_COUNTRECS; global $ADODB_COUNTRECS;

View File

@ -129,14 +129,21 @@ class ADODB_text extends ADOConnection {
return true; return true;
} }
/**
* Execute a query.
// returns queryID or false *
// We presume that the select statement is on the same table (what else?), * We presume that the select statement is on the same table (what else?),
// with the only difference being the order by. * with the only difference being the order by.
//You can filter by using $eval and each clause is stored in $arr .eg. $arr[1] == 'name' * You can filter by using $eval and each clause is stored in $arr e.g. $arr[1] == 'name'
// also supports SELECT [DISTINCT] COL FROM ... -- only 1 col supported * also supports SELECT [DISTINCT] COL FROM ... -- only 1 col supported
function _query($sql,$input_arr,$eval=false) *
* @param string|array $sql Query to execute.
* @param array $inputarr An optional array of parameters.
* @param string $eval Optional eval string
*
* @return mixed|bool Query identifier or true if execution successful, false if failed.
*/
function _query($sql, $inputarr=false, $eval=false)
{ {
if ($this->_origarray === false) return false; if ($this->_origarray === false) return false;

View File

@ -23,7 +23,7 @@
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
class perf_oci8 extends ADODB_perf{ class perf_oci8 extends adodb_perf{
var $noShowIxora = 15; // if the sql for suspicious sql is taking too long, then disable ixora var $noShowIxora = 15; // if the sql for suspicious sql is taking too long, then disable ixora

View File

@ -23,6 +23,3 @@ Removed:
Added: Added:
* index.html - prevent directory browsing on misconfigured servers * index.html - prevent directory browsing on misconfigured servers
* readme_moodle.txt - this file ;-) * readme_moodle.txt - this file ;-)
Notes:
* 2023-09-28 Added #[AllowDynamicProperties] above the ADOFetchObj class.

View File

@ -141,7 +141,10 @@ GLOBAL $gSQLMaxRows,$gSQLBlockRows,$ADODB_ROUND;
default: default:
if ($v) { if ($v) {
$v = htmlspecialchars(stripslashes(trim($v))); $v = trim($v);
if ($htmlspecialchars) {
$v = htmlspecialchars($v);
}
} elseif ($v === null) { } elseif ($v === null) {
$v = '(NULL)'; $v = '(NULL)';
} else { } else {

View File

@ -4,7 +4,7 @@
<location>adodb</location> <location>adodb</location>
<name>AdoDB</name> <name>AdoDB</name>
<description>Database abstraction library for MySQL, PostgreSQL, MSSQL, Oracle, Interbase, Foxpro, Access, ADO, Sybase, DB2 and ODBC.</description> <description>Database abstraction library for MySQL, PostgreSQL, MSSQL, Oracle, Interbase, Foxpro, Access, ADO, Sybase, DB2 and ODBC.</description>
<version>5.22.5</version> <version>5.22.7</version>
<license>BSD/LGPL</license> <license>BSD/LGPL</license>
<licenseversion>3-Clause/2.1+</licenseversion> <licenseversion>3-Clause/2.1+</licenseversion>
<repository>https://github.com/ADOdb/ADOdb</repository> <repository>https://github.com/ADOdb/ADOdb</repository>