Skip to content

Commit

Permalink
Define ADOConnection::_query() method
Browse files Browse the repository at this point in the history
- Update child classes to be consistent with this declaration.
- Remove unnecessary, non-PHPDoc comments
- Consistent parameter names

Fixes #966
  • Loading branch information
dregad committed Apr 29, 2023
1 parent aef9e94 commit ae2438b
Show file tree
Hide file tree
Showing 21 changed files with 70 additions and 53 deletions.
12 changes: 12 additions & 0 deletions adodb.inc.php
Expand Up @@ -1666,6 +1666,18 @@ function _Execute($sql,$inputarr=false) {
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) {
if (empty($this->_genSeqSQL)) {
return false;
Expand Down
4 changes: 0 additions & 4 deletions drivers/adodb-ado.inc.php
Expand Up @@ -208,10 +208,6 @@ function MetaColumns($table, $normalize=true)
return empty($arr) ? $false : $arr;
}




/* returns queryID or false */
function _query($sql,$inputarr=false)
{

Expand Down
1 change: 0 additions & 1 deletion drivers/adodb-ado5.inc.php
Expand Up @@ -233,7 +233,6 @@ function MetaColumns($table, $normalize=true)
return $arr;
}

/* returns queryID or false */
function _query($sql,$inputarr=false)
{
try { // In PHP5, all COM errors are exceptions, so to maintain old behaviour...
Expand Down
1 change: 0 additions & 1 deletion drivers/adodb-ads.inc.php
Expand Up @@ -564,7 +564,6 @@ function Prepare($sql)
return array($sql, $stmt, false);
}

/* returns queryID or false */
function _query($sql, $inputarr = false)
{
$last_php_error = $this->resetLastError();
Expand Down
1 change: 0 additions & 1 deletion drivers/adodb-fbsql.inc.php
Expand Up @@ -134,7 +134,6 @@ function SelectDB($dbName)
}


// returns queryID or false
function _query($sql,$inputarr=false)
{
return fbsql_query("$sql;",$this->_connectionID);
Expand Down
20 changes: 10 additions & 10 deletions drivers/adodb-firebird.inc.php
Expand Up @@ -483,14 +483,14 @@ public function prepare($sql)
}

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

Expand Down
18 changes: 9 additions & 9 deletions drivers/adodb-ibase.inc.php
Expand Up @@ -332,7 +332,7 @@ function Prepare($sql)

// returns query ID if successful, otherwise false
// 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) {
$conn = $this->_transactionID;
Expand All @@ -344,23 +344,23 @@ function _query($sql,$iarr=false)
if (is_array($sql)) {
$fn = 'ibase_execute';
$sql = $sql[1];
if (is_array($iarr)) {
if (!isset($iarr[0])) {
$iarr[0] = ''; // PHP5 compat hack
if (is_array($inputarr)) {
if (!isset($inputarr[0])) {
$inputarr[0] = ''; // PHP5 compat hack
}
$fnarr = array_merge(array($sql), $iarr);
$fnarr = array_merge(array($sql), $inputarr);
$ret = call_user_func_array($fn, $fnarr);
} else {
$ret = $fn($sql);
}
} else {
$fn = 'ibase_query';

if (is_array($iarr)) {
if (sizeof($iarr) == 0) {
$iarr[0] = ''; // PHP5 compat hack
if (is_array($inputarr)) {
if (sizeof($inputarr) == 0) {
$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);
} else {
$ret = $fn($conn, $sql);
Expand Down
1 change: 0 additions & 1 deletion drivers/adodb-informix72.inc.php
Expand Up @@ -334,7 +334,6 @@ function Prepare($sql)
else return array($sql,$stmt);
}
*/
// returns query ID if successful, otherwise false
function _query($sql,$inputarr=false)
{
global $ADODB_COUNTRECS;
Expand Down
1 change: 0 additions & 1 deletion drivers/adodb-ldap.inc.php
Expand Up @@ -157,7 +157,6 @@ function _inject_bind_options( $options ) {
}
}

/* returns _queryID or false */
function _query($sql,$inputarr=false)
{
$rs = @ldap_search( $this->_connectionID, $this->database, $sql );
Expand Down
1 change: 0 additions & 1 deletion drivers/adodb-mssql.inc.php
Expand Up @@ -725,7 +725,6 @@ function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
return $this->Execute($sql) != false;
}

// returns query ID if successful, otherwise false
function _query($sql,$inputarr=false)
{
$this->_errorMsg = false;
Expand Down
14 changes: 7 additions & 7 deletions drivers/adodb-mysqli.inc.php
Expand Up @@ -1179,14 +1179,14 @@ private function getBindParamWithType($inputArr): array
}

/**
* Return the query id.
*
* @param string|array $sql
* @param array $inputarr
*
* @return bool|mysqli_result
* Execute a query.
*
* @param string|array $sql Query to execute.
* @param array $inputarr An optional array of parameters.
*
* @return mysqli_result|bool
*/
function _query($sql, $inputarr)
function _query($sql, $inputarr = false)
{
global $ADODB_COUNTRECS;
// Move to the next recordset, or return false if there is none. In a stored proc
Expand Down
8 changes: 7 additions & 1 deletion drivers/adodb-oci8.inc.php
Expand Up @@ -1272,7 +1272,8 @@ function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false)
}

/**
* returns query ID if successful, otherwise false
* Execute a query.
*
* this version supports:
*
* 1. $db->execute('select * from table');
Expand All @@ -1285,6 +1286,11 @@ function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false)
* 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->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)
{
Expand Down
11 changes: 10 additions & 1 deletion drivers/adodb-oci8po.inc.php
Expand Up @@ -70,7 +70,16 @@ function SelectLimit($sql, $nrows=-1, $offset=-1, $inputarr=false, $secs2cache=0
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)
{
if (is_array($inputarr)) {
Expand Down
1 change: 0 additions & 1 deletion drivers/adodb-odbc.inc.php
Expand Up @@ -518,7 +518,6 @@ function Prepare($sql)
return array($sql,$stmt,false);
}

/* returns queryID or false */
function _query($sql,$inputarr=false)
{
$last_php_error = $this->resetLastError();
Expand Down
1 change: 0 additions & 1 deletion drivers/adodb-oracle.inc.php
Expand Up @@ -181,7 +181,6 @@ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
}


// returns query ID if successful, otherwise false
function _query($sql,$inputarr=false)
{
// <G. Giunta 2003/03/03/> Reset error messages before executing
Expand Down
1 change: 0 additions & 1 deletion drivers/adodb-pdo.inc.php
Expand Up @@ -578,7 +578,6 @@ function GenID($seqname='adodbseq',$startID=1)
}


/* returns queryID or false */
function _query($sql,$inputarr=false)
{
$ok = false;
Expand Down
1 change: 0 additions & 1 deletion drivers/adodb-postgres64.inc.php
Expand Up @@ -784,7 +784,6 @@ function _pconnect($str,$user='',$pwd='',$db='')
}


// returns queryID or false
function _query($sql,$inputarr=false)
{
$this->_pnum = 0;
Expand Down
1 change: 0 additions & 1 deletion drivers/adodb-sqlite.inc.php
Expand Up @@ -211,7 +211,6 @@ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
return true;
}

// returns query ID if successful, otherwise false
function _query($sql,$inputarr=false)
{
$rez = sqlite_query($sql,$this->_connectionID);
Expand Down
1 change: 0 additions & 1 deletion drivers/adodb-sqlite3.inc.php
Expand Up @@ -331,7 +331,6 @@ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
}

// returns query ID if successful, otherwise false
function _query($sql,$inputarr=false)
{
$rez = $this->_connectionID->query($sql);
Expand Down
1 change: 0 additions & 1 deletion drivers/adodb-sybase.inc.php
Expand Up @@ -170,7 +170,6 @@ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
return true;
}

// returns query ID if successful, otherwise false
function _query($sql,$inputarr=false)
{
global $ADODB_COUNTRECS;
Expand Down
23 changes: 15 additions & 8 deletions drivers/adodb-text.inc.php
Expand Up @@ -129,14 +129,21 @@ function Connect(&$array, $types = false, $colnames = false)
return true;
}



// returns queryID or false
// We presume that the select statement is on the same table (what else?),
// 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'
// also supports SELECT [DISTINCT] COL FROM ... -- only 1 col supported
function _query($sql,$input_arr,$eval=false)
/**
* Execute a query.
*
* We presume that the select statement is on the same table (what else?),
* with the only difference being the order by.
* 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
*
* @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;

Expand Down

0 comments on commit ae2438b

Please sign in to comment.