diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/adodb-ado.inc.php | 10 | ||||
| -rw-r--r-- | drivers/adodb-ado5.inc.php | 10 | ||||
| -rw-r--r-- | drivers/adodb-ads.inc.php | 23 | ||||
| -rw-r--r-- | drivers/adodb-db2.inc.php | 11 | ||||
| -rw-r--r-- | drivers/adodb-fbsql.inc.php | 24 | ||||
| -rw-r--r-- | drivers/adodb-firebird.inc.php | 18 | ||||
| -rw-r--r-- | drivers/adodb-ibase.inc.php | 7 | ||||
| -rw-r--r-- | drivers/adodb-informix72.inc.php | 11 | ||||
| -rw-r--r-- | drivers/adodb-ldap.inc.php | 35 | ||||
| -rw-r--r-- | drivers/adodb-mssql.inc.php | 12 | ||||
| -rw-r--r-- | drivers/adodb-mssqlnative.inc.php | 49 | ||||
| -rw-r--r-- | drivers/adodb-mysqli.inc.php | 166 | ||||
| -rw-r--r-- | drivers/adodb-oci8.inc.php | 123 | ||||
| -rw-r--r-- | drivers/adodb-odbc.inc.php | 11 | ||||
| -rw-r--r-- | drivers/adodb-odbtp.inc.php | 9 | ||||
| -rw-r--r-- | drivers/adodb-oracle.inc.php | 15 | ||||
| -rw-r--r-- | drivers/adodb-pdo.inc.php | 99 | ||||
| -rw-r--r-- | drivers/adodb-postgres64.inc.php | 335 | ||||
| -rw-r--r-- | drivers/adodb-sqlite.inc.php | 13 | ||||
| -rw-r--r-- | drivers/adodb-sqlite3.inc.php | 11 | ||||
| -rw-r--r-- | drivers/adodb-sybase.inc.php | 14 |
21 files changed, 420 insertions, 586 deletions
diff --git a/drivers/adodb-ado.inc.php b/drivers/adodb-ado.inc.php index df95c690..30edf28b 100644 --- a/drivers/adodb-ado.inc.php +++ b/drivers/adodb-ado.inc.php @@ -345,16 +345,6 @@ class ADORecordSet_ado extends ADORecordSet { var $canSeek = true; var $hideErrors = true; - function __construct($id,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - $this->fetchMode = $mode; - parent::__construct($id); - } - // returns the field object function FetchField($fieldOffset = -1) { diff --git a/drivers/adodb-ado5.inc.php b/drivers/adodb-ado5.inc.php index 04b45abf..53bdc6a1 100644 --- a/drivers/adodb-ado5.inc.php +++ b/drivers/adodb-ado5.inc.php @@ -382,16 +382,6 @@ class ADORecordSet_ado extends ADORecordSet { var $canSeek = true; var $hideErrors = true; - function __construct($id,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - $this->fetchMode = $mode; - parent::__construct($id); - } - // returns the field object function FetchField($fieldOffset = -1) { diff --git a/drivers/adodb-ads.inc.php b/drivers/adodb-ads.inc.php index 16eec976..e6cd4f3b 100644 --- a/drivers/adodb-ads.inc.php +++ b/drivers/adodb-ads.inc.php @@ -287,7 +287,7 @@ class ADODB_ads extends ADOConnection // Returns tables,Views or both on successful execution. Returns // tables by default on successful execution. - function &MetaTables($ttype = false, $showSchema = false, $mask = false) + function MetaTables($ttype = false, $showSchema = false, $mask = false) { $recordSet1 = $this->Execute("select * from system.tables"); if (!$recordSet1) { @@ -325,7 +325,7 @@ class ADODB_ads extends ADOConnection } - function &MetaPrimaryKeys($table, $owner = false) + function MetaPrimaryKeys($table, $owner = false) { $recordSet = $this->Execute("select table_primary_key from system.tables where name='$table'"); if (!$recordSet) { @@ -533,7 +533,7 @@ class ADODB_ads extends ADOConnection } // Returns an array of columns names for a given table - function &MetaColumnNames($table, $numIndexes = false, $useattnum = false) + function MetaColumnNames($table, $numIndexes = false, $useattnum = false) { $recordSet = $this->Execute("select name from system.columns where parent='$table'"); if (!$recordSet) { @@ -684,20 +684,13 @@ class ADORecordSet_ads extends ADORecordSet var $dataProvider = "ads"; var $useFetchArray; - function __construct($id, $mode = false) + function __construct($queryID, $mode = false) { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - $this->fetchMode = $mode; - - $this->_queryID = $id; + parent::__construct($queryID, $mode); // the following is required for mysql odbc driver in 4.3.1 -- why? $this->EOF = false; $this->_currentRow = -1; - //parent::__construct($id); } @@ -760,7 +753,7 @@ class ADORecordSet_ads extends ADORecordSet function &GetArrayLimit($nrows, $offset = -1) { if ($offset <= 0) { - $rs =& $this->GetArray($nrows); + $rs = $this->GetArray($nrows); return $rs; } $savem = $this->fetchMode; @@ -769,7 +762,7 @@ class ADORecordSet_ads extends ADORecordSet $this->fetchMode = $savem; if ($this->fetchMode & ADODB_FETCH_ASSOC) { - $this->fields =& $this->GetRowAssoc(); + $this->fields = $this->GetRowAssoc(); } $results = array(); @@ -802,7 +795,7 @@ class ADORecordSet_ads extends ADORecordSet $rez = @ads_fetch_into($this->_queryID, $this->fields); if ($rez) { if ($this->fetchMode & ADODB_FETCH_ASSOC) { - $this->fields =& $this->GetRowAssoc(); + $this->fields = $this->GetRowAssoc(); } return true; } diff --git a/drivers/adodb-db2.inc.php b/drivers/adodb-db2.inc.php index e214d2d7..9a3a90c5 100644 --- a/drivers/adodb-db2.inc.php +++ b/drivers/adodb-db2.inc.php @@ -1832,17 +1832,6 @@ class ADORecordSet_db2 extends ADORecordSet { var $dataProvider = "db2"; var $useFetchArray; - function __construct($id,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - $this->fetchMode = $mode; - - $this->_queryID = $id; - } - // returns the field object function fetchField($offset = 0) diff --git a/drivers/adodb-fbsql.inc.php b/drivers/adodb-fbsql.inc.php index 64913bc2..ca2df2da 100644 --- a/drivers/adodb-fbsql.inc.php +++ b/drivers/adodb-fbsql.inc.php @@ -169,20 +169,22 @@ class ADORecordSet_fbsql extends ADORecordSet{ var $databaseType = "fbsql"; var $canSeek = true; - function __construct($queryID,$mode=false) + function __construct($queryID, $mode=false) { - if (!$mode) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } + parent::__construct($queryID, $mode); + switch ($mode) { - case ADODB_FETCH_NUM: $this->fetchMode = FBSQL_NUM; break; - case ADODB_FETCH_ASSOC: $this->fetchMode = FBSQL_ASSOC; break; - case ADODB_FETCH_BOTH: - default: - $this->fetchMode = FBSQL_BOTH; break; + case ADODB_FETCH_NUM: + $this->fetchMode = FBSQL_NUM; + break; + case ADODB_FETCH_ASSOC: + $this->fetchMode = FBSQL_ASSOC; + break; + case ADODB_FETCH_BOTH: + default: + $this->fetchMode = FBSQL_BOTH; + break; } - parent::__construct($queryID); } function _initrs() diff --git a/drivers/adodb-firebird.inc.php b/drivers/adodb-firebird.inc.php index db3cca5d..848b3c4e 100644 --- a/drivers/adodb-firebird.inc.php +++ b/drivers/adodb-firebird.inc.php @@ -1020,28 +1020,10 @@ class ADORecordset_firebird extends ADORecordSet private $fieldObjects = false; /** - * @var bool Flags if we have retrieved the metadata - */ - private $fieldObjectsRetrieved = false; - - /** - * @var array Cross-reference the objects by name for easy access - */ - private $fieldObjectsIndex = array(); - - /** * @var bool Flag to indicate if the result has a blob */ private $fieldObjectsHaveBlob = false; - function __construct($id, $mode = false) - { - global $ADODB_FETCH_MODE; - - $this->fetchMode = ($mode === false) ? $ADODB_FETCH_MODE : $mode; - parent::__construct($id); - } - /** * Returns: an object containing field information. diff --git a/drivers/adodb-ibase.inc.php b/drivers/adodb-ibase.inc.php index 8159c512..8d48f17d 100644 --- a/drivers/adodb-ibase.inc.php +++ b/drivers/adodb-ibase.inc.php @@ -741,13 +741,6 @@ class ADORecordSet_ibase extends ADORecordSet var $bind=false; var $_cacheType; - function __construct($id,$mode=false) - { - global $ADODB_FETCH_MODE; - - $this->fetchMode = ($mode === false) ? $ADODB_FETCH_MODE : $mode; - parent::__construct($id); - } /* Returns: an object containing field information. Get column information in the Recordset object. fetchField() can be used in order to obtain information about diff --git a/drivers/adodb-informix72.inc.php b/drivers/adodb-informix72.inc.php index 6fddde3d..d4083d5e 100644 --- a/drivers/adodb-informix72.inc.php +++ b/drivers/adodb-informix72.inc.php @@ -399,17 +399,6 @@ class ADORecordset_informix72 extends ADORecordSet { var $canSeek = true; var $_fieldprops = false; - function __construct($id,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - $this->fetchMode = $mode; - parent::__construct($id); - } - - /* Returns: an object containing field information. Get column information in the Recordset object. fetchField() can be used in order to obtain information about diff --git a/drivers/adodb-ldap.inc.php b/drivers/adodb-ldap.inc.php index 305f6a7f..e81cb818 100644 --- a/drivers/adodb-ldap.inc.php +++ b/drivers/adodb-ldap.inc.php @@ -295,28 +295,23 @@ class ADORecordSet_ldap extends ADORecordSet{ var $canSeek = false; var $_entryID; /* keeps track of the entry resource identifier */ - function __construct($queryID,$mode=false) + function __construct($queryID, $mode=false) { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - switch ($mode) - { - case ADODB_FETCH_NUM: - $this->fetchMode = LDAP_NUM; - break; - case ADODB_FETCH_ASSOC: - $this->fetchMode = LDAP_ASSOC; - break; - case ADODB_FETCH_DEFAULT: - case ADODB_FETCH_BOTH: - default: - $this->fetchMode = LDAP_BOTH; - break; - } + parent::__construct($queryID, $mode); - parent::__construct($queryID); + switch ($mode) { + case ADODB_FETCH_NUM: + $this->fetchMode = LDAP_NUM; + break; + case ADODB_FETCH_ASSOC: + $this->fetchMode = LDAP_ASSOC; + break; + case ADODB_FETCH_DEFAULT: + case ADODB_FETCH_BOTH: + default: + $this->fetchMode = LDAP_BOTH; + break; + } } function _initrs() diff --git a/drivers/adodb-mssql.inc.php b/drivers/adodb-mssql.inc.php index c0b714ed..c0a2eabd 100644 --- a/drivers/adodb-mssql.inc.php +++ b/drivers/adodb-mssql.inc.php @@ -857,18 +857,12 @@ class ADORecordset_mssql extends ADORecordSet { var $hasFetchAssoc; // see PHPLens Issue No: 6083 // _mths works only in non-localised system - function __construct($id,$mode=false) + function __construct($queryID, $mode=false) { + parent::__construct($queryID, $mode); + // freedts check... $this->hasFetchAssoc = function_exists('mssql_fetch_assoc'); - - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - - } - $this->fetchMode = $mode; - return parent::__construct($id); } diff --git a/drivers/adodb-mssqlnative.inc.php b/drivers/adodb-mssqlnative.inc.php index f7e1bcc1..a7640625 100644 --- a/drivers/adodb-mssqlnative.inc.php +++ b/drivers/adodb-mssqlnative.inc.php @@ -136,26 +136,12 @@ class ADODB_mssqlnative extends ADOConnection { $this->mssql_version = $version; } - function ServerInfo() { - global $ADODB_FETCH_MODE; - static $arr = false; - if (is_array($arr)) - return $arr; - if ($this->fetchMode === false) { - $savem = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - } elseif ($this->fetchMode >=0 && $this->fetchMode <=2) { - $savem = $this->fetchMode; - } else - $savem = $this->SetFetchMode(ADODB_FETCH_NUM); - - $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']); - return $arr; + function serverInfo() { + $info = sqlsrv_server_info($this->_connectionID); + return array( + 'description' => $info['SQLServerName'] . ' connected to ' . $info['CurrentDatabase'], + 'version' => $info['SQLServerVersion'], + ); } function IfNull( $field, $ifNull ) @@ -1053,15 +1039,6 @@ class ADORecordset_mssqlnative extends ADORecordSet { var $fieldOffset = 0; // _mths works only in non-localised system - /** - * @var bool True if we have retrieved the fields metadata - */ - private $fieldObjectsRetrieved = false; - - /* - * Cross-reference the objects by name for easy access - */ - private $fieldObjectsIndex = array(); /* * Cross references the dateTime objects for faster decoding @@ -1107,20 +1084,6 @@ class ADORecordset_mssqlnative extends ADORecordSet { ); - - - function __construct($id,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - - } - $this->fetchMode = $mode; - parent::__construct($id); - } - - function _initrs() { $this->_numOfRows = -1;//not supported diff --git a/drivers/adodb-mysqli.inc.php b/drivers/adodb-mysqli.inc.php index 07b294ca..62c28949 100644 --- a/drivers/adodb-mysqli.inc.php +++ b/drivers/adodb-mysqli.inc.php @@ -66,7 +66,6 @@ class ADODB_mysqli extends ADOConnection { var $socket = ''; //Default to empty string to fix HHVM bug var $_bindInputArray = false; var $nameQuote = '`'; /// string to use to quote identifiers and names - var $optionFlags = array(array(MYSQLI_READ_DEFAULT_GROUP,0)); var $arrayClass = 'ADORecordSet_array_mysqli'; var $multiQuery = false; var $ssl_key = null; @@ -176,15 +175,6 @@ class ADODB_mysqli extends ADOConnection { } return false; } - /* - I suggest a simple fix which would enable adodb and mysqli driver to - read connection options from the standard mysql configuration file - /etc/my.cnf - "Bastien Duclaux" <bduclaux#yahoo.com> - */ - $this->optionFlags = array(); - foreach($this->optionFlags as $arr) { - mysqli_options($this->_connectionID,$arr[0],$arr[1]); - } // Now merge in the standard connection parameters setting foreach ($this->connectionParameters as $options) { @@ -211,7 +201,6 @@ class ADODB_mysqli extends ADOConnection { $this->clientFlags = MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT; } - #if (!empty($this->port)) $argHostname .= ":".$this->port; /** @noinspection PhpCastIsUnnecessaryInspection */ $ok = @mysqli_real_connect($this->_connectionID, $argHostname, @@ -747,8 +736,6 @@ class ADODB_mysqli extends ADOConnection { $fraction = $dayFraction * 24 * 3600; return $date . ' + INTERVAL ' . $fraction.' SECOND'; - -// return "from_unixtime(unix_timestamp($date)+$fraction)"; } /** @@ -1015,7 +1002,6 @@ class ADODB_mysqli extends ADOConnection { */ function SelectDB($dbName) { -// $this->_connectionID = $this->mysqli_resolve_link($this->_connectionID); $this->database = $dbName; if ($this->_connectionID) { @@ -1074,21 +1060,11 @@ class ADODB_mysqli extends ADOConnection { */ function Prepare($sql) { - /* - * Flag the insert_id method to use the correct retrieval method - */ + // Flag the insert_id method to use the correct retrieval method $this->usePreparedStatement = true; - /* - * Prepared statements are not yet handled correctly - */ + // Prepared statements are not yet handled correctly return $sql; - $stmt = $this->_connectionID->prepare($sql); - if (!$stmt) { - echo $this->errorMsg(); - return $sql; - } - return array($sql,$stmt); } public function execute($sql, $inputarr = false) @@ -1189,12 +1165,6 @@ class ADODB_mysqli extends ADOConnection { function _query($sql, $inputarr = false) { global $ADODB_COUNTRECS; - // Move to the next recordset, or return false if there is none. In a stored proc - // call, mysqli_next_result returns true for the last "recordset", but mysqli_store_result - // returns false. I think this is because the last "recordset" is actually just the - // return value of the stored proc (ie the number of rows affected). - // Commented out for reasons of performance. You should retrieve every recordset yourself. - // if (!mysqli_next_result($this->connection->_connectionID)) return false; // When SQL is empty, mysqli_query() throws exception on PHP 8 (#945) if (!$sql) { @@ -1204,80 +1174,39 @@ class ADODB_mysqli extends ADOConnection { return false; } - if (is_array($sql)) { - - // Prepare() not supported because mysqli_stmt_execute does not return a recordset, but - // returns as bound variables. - - $stmt = $sql[1]; - $a = ''; - foreach($inputarr as $v) { - if (is_string($v)) $a .= 's'; - else if (is_integer($v)) $a .= 'i'; - else $a .= 'd'; - } - - /* - * set prepared statement flags - */ - if ($this->usePreparedStatement) - $this->useLastInsertStatement = true; - - $fnarr = array_merge( array($stmt,$a) , $inputarr); - call_user_func_array('mysqli_stmt_bind_param',$fnarr); - return mysqli_stmt_execute($stmt); - } - else if (is_string($sql) && is_array($inputarr)) - { - - /* - * This is support for true prepared queries - * with bound parameters - * - * set prepared statement flags - */ + if (is_string($sql) && is_array($inputarr)) { + // This is support for true prepared queries with bound parameters + // set prepared statement flags $this->usePreparedStatement = true; $this->usingBoundVariables = true; $bulkBindArray = array(); - if (is_array($inputarr[0])) - { + if (is_array($inputarr[0])) { $bulkBindArray = $inputarr; $inputArrayCount = count($inputarr[0]) - 1; - } - else - { + } else { $bulkBindArray[] = $inputarr; $inputArrayCount = count($inputarr) - 1; } - - /* - * Prepare the statement with the placeholders, - * prepare will fail if the statement is invalid - * so we trap and error if necessary. Note that we - * are calling MySQL prepare here, not ADOdb - */ + // Prepare the statement with the placeholders + // prepare will fail if the statement is invalid, so we trap and error if necessary. + // Note that we are calling MySQL prepare here, not ADOdb $stmt = $this->_connectionID->prepare($sql); - if ($stmt === false) - { + if ($stmt === false) { $this->outp_throw( "SQL Statement failed on preparation: " . htmlspecialchars($sql) . "'", 'Execute' ); return false; } - /* - * Make sure the number of parameters provided in the input - * array matches what the query expects. We must discount - * the first parameter which contains the data types in - * our inbound parameters - */ - $nparams = $stmt->param_count; - if ($nparams != $inputArrayCount) - { + // Make sure the number of parameters provided in the input array + // matches what the query expects. We must discount the first + // parameter which contains the data types in our inbound parameters + $nparams = $stmt->param_count; + if ($nparams != $inputArrayCount) { $this->outp_throw( "Input array has " . $inputArrayCount . " params, does not match query: '" . htmlspecialchars($sql) . "'", @@ -1286,37 +1215,28 @@ class ADODB_mysqli extends ADOConnection { return false; } - foreach ($bulkBindArray as $inputarr) - { - /* - * Must pass references into call_user_func_array - */ + foreach ($bulkBindArray as $inputarr) { + // Must pass references into call_user_func_array $paramsByReference = array(); - foreach($inputarr as $key => $value) { + foreach ($inputarr as $key => $value) { /** @noinspection PhpArrayAccessCanBeReplacedWithForeachValueInspection */ $paramsByReference[$key] = &$inputarr[$key]; } - /* - * Bind the params - */ + // Bind the params call_user_func_array(array($stmt, 'bind_param'), $paramsByReference); - /* - * Execute - */ - + // Execute $ret = mysqli_stmt_execute($stmt); // Store error code and message $this->_errorCode = $stmt->errno; $this->_errorMsg = $stmt->error; - /* - * Did we throw an error? - */ - if ($ret == false) + // Did we throw an error? + if (!$ret) { return false; + } } // Tells affected_rows to be compliant @@ -1328,14 +1248,9 @@ class ADODB_mysqli extends ADOConnection { // Turn the statement into a result set and return it return $stmt->get_result(); - } - else - { - /* - * reset prepared statement flags, in case we set them - * previously and didn't use them - */ - $this->usePreparedStatement = false; + } else { + // Reset prepared statement flags, in case we set them previously and didn't use them + $this->usePreparedStatement = false; $this->useLastInsertStatement = false; // Reset error code and message @@ -1343,19 +1258,12 @@ class ADODB_mysqli extends ADOConnection { $this->_errorMsg = ''; } - /* - if (!$mysql_res = mysqli_query($this->_connectionID, $sql, ($ADODB_COUNTRECS) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT)) { - if ($this->debug) ADOConnection::outp("Query: " . $sql . " failed. " . $this->errorMsg()); - return false; - } - - return $mysql_res; - */ - if ($this->multiQuery) { - $rs = mysqli_multi_query($this->_connectionID, $sql.';'); + $rs = mysqli_multi_query($this->_connectionID, $sql . ';'); if ($rs) { - $rs = ($ADODB_COUNTRECS) ? @mysqli_store_result( $this->_connectionID ) : @mysqli_use_result( $this->_connectionID ); + $rs = ($ADODB_COUNTRECS) + ? @mysqli_store_result($this->_connectionID) + : @mysqli_use_result($this->_connectionID); return $rs ?: true; // mysqli_more_results( $this->_connectionID ) } } else { @@ -1366,11 +1274,10 @@ class ADODB_mysqli extends ADOConnection { } } - if($this->debug) + if ($this->debug) { ADOConnection::outp("Query: " . $sql . " failed. " . $this->errorMsg()); - + } return false; - } /** @@ -1492,10 +1399,7 @@ class ADORecordSet_mysqli extends ADORecordSet{ function __construct($queryID, $mode = false) { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } + parent::__construct($queryID, $mode); switch ($mode) { case ADODB_FETCH_NUM: @@ -1510,8 +1414,6 @@ class ADORecordSet_mysqli extends ADORecordSet{ $this->fetchMode = MYSQLI_BOTH; break; } - $this->adodbFetchMode = $mode; - parent::__construct($queryID); } function _initrs() diff --git a/drivers/adodb-oci8.inc.php b/drivers/adodb-oci8.inc.php index f361d683..2c2c891a 100644 --- a/drivers/adodb-oci8.inc.php +++ b/drivers/adodb-oci8.inc.php @@ -105,8 +105,6 @@ END; var $datetime = false; // MetaType('DATE') returns 'D' (datetime==false) or 'T' (datetime == true) var $_refLOBs = array(); - // var $ansiOuter = true; // if oracle9 - /* * Legacy compatibility for sequence names for emulated auto-increments */ @@ -193,21 +191,33 @@ END; } /** + * Connect to database. + * * Multiple modes of connection are supported: * - * a. Local Database - * $conn->Connect(false,'scott','tiger'); + * 1. Local Database + * $conn->connect(false, 'scott', 'tiger'); * - * b. From tnsnames.ora - * $conn->Connect($tnsname,'scott','tiger'); - * $conn->Connect(false,'scott','tiger',$tnsname); + * 2. From tnsnames.ora + * $conn->connect($tnsname, 'scott', 'tiger'); + * OR + * $conn->connect(false, 'scott', 'tiger', $tnsname); * - * c. Server + service name - * $conn->Connect($serveraddress,'scott,'tiger',$service_name); + * 3. Server + service name + * $conn->connect($serveraddress, 'scott, 'tiger', $service_name); * - * d. Server + SID + * 4. Server + SID * $conn->connectSID = true; * $conn->Connect($serveraddress,'scott,'tiger',$SID); + * OR + * $conn->Connect($serveraddress,'scott,'tiger',"SID=$SID"); + * + * By default, the Session Mode will be set to OCI_DEFAULT, but it is + * possible to use one of other modes referenced in the + * {@link https://www.php.net/manual/en/function.oci-connect oci8_connect()} + * function's documentation, like this: + * $conn->setConnectionParameter('session_mode', OCI_SYSDBA); + * $conn->connect(...); * * @param string|false $argHostname DB server hostname or TNS name * @param string $argUsername @@ -245,45 +255,60 @@ END; $argDatabasename = substr($argDatabasename,4); $this->connectSID = true; } - - if ($this->connectSID) { - $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname - .")(PORT=$argHostport))(CONNECT_DATA=(SID=$argDatabasename)))"; - } else - $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname - .")(PORT=$argHostport))(CONNECT_DATA=(SERVICE_NAME=$argDatabasename)))"; + $sidOrService = $this->connectSID ? 'SID' : 'SERVICE_NAME'; + $argDatabasename = "(DESCRIPTION=" + . "(ADDRESS=(PROTOCOL=TCP)(HOST=$argHostname)(PORT=$argHostport))" + . "(CONNECT_DATA=($sidOrService=$argDatabasename)))"; } } - //if ($argHostname) print "<p>Connect: 1st argument should be left blank for $this->databaseType</p>"; - if ($mode==1) { - $this->_connectionID = ($this->charSet) - ? oci_pconnect($argUsername,$argPassword, $argDatabasename,$this->charSet) - : oci_pconnect($argUsername,$argPassword, $argDatabasename); - if ($this->_connectionID && $this->autoRollback) { - oci_rollback($this->_connectionID); + // Determine the connect function to use based on connection mode + switch ($mode) { + case 1: $ociConnectFunction = 'oci_pconnect'; break; + case 2: $ociConnectFunction = 'oci_new_connect'; break; + default: $ociConnectFunction = 'oci_connect'; + } + + // Process the connection parameters + $sessionMode = OCI_DEFAULT; + $clientIdentifier = ''; + foreach ($this->connectionParameters as $options) { + foreach($options as $parameter => $value) { + switch ($parameter) { + case 'session_mode': + $sessionMode = $value; + break; + case 'client_identifier': + $clientIdentifier = $value; + break; + } } - } else if ($mode==2) { - $this->_connectionID = ($this->charSet) - ? oci_new_connect($argUsername,$argPassword, $argDatabasename,$this->charSet) - : oci_new_connect($argUsername,$argPassword, $argDatabasename); - } else { - $this->_connectionID = ($this->charSet) - ? oci_connect($argUsername,$argPassword, $argDatabasename,$this->charSet) - : oci_connect($argUsername,$argPassword, $argDatabasename); } + + $this->_connectionID = $ociConnectFunction( + $argUsername, + $argPassword, + $argDatabasename, + $this->charSet ?: '', + $sessionMode + ); if (!$this->_connectionID) { return false; } + // Set client identifier, but see documentation for limitations + if ($clientIdentifier) { + oci_set_client_identifier($this->_connectionID, $clientIdentifier); + } + + if ($mode == 1 && $this->autoRollback ) { + oci_rollback($this->_connectionID); + } + if ($this->_initdate) { $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'"); } - // looks like: - // Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production With the Partitioning option JServer Release 8.1.7.0.0 - Production - // $vers = oci_server_version($this->_connectionID); - // if (strpos($vers,'8i') !== false) $this->ansiOuter = true; return true; } @@ -547,7 +572,7 @@ END; $ok = true; } - return $ok ? true : false; + return (bool)$ok; } function CommitTrans($ok=true) @@ -1252,9 +1277,9 @@ END; * $db->Parameter($stmt,$group,'group'); * $db->Execute($stmt); * - * @param $stmt Statement returned by {@see Prepare()} or {@see PrepareSP()}. - * @param $var PHP variable to bind to - * @param $name Name of stored procedure variable name to bind to. + * @param array $stmt Statement returned by {@see Prepare()} or {@see PrepareSP()}. + * @param mixed $var PHP variable to bind to + * @param string $name Name of stored procedure variable name to bind to. * @param bool $isOutput Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8. * @param int $maxLen Holds an maximum length of the variable. * @param mixed $type The data type of $var. Legal values depend on driver. @@ -1398,15 +1423,13 @@ END; $ok = oci_execute($cursor); return $cursor; } - return $stmt; } else { if (is_resource($stmt)) { oci_free_statement($stmt); return true; } - return $stmt; } - break; + return $stmt; default : return true; @@ -1571,8 +1594,6 @@ SELECT /*+ RULE */ distinct b.column_name * It remains for backwards compatibility. * * @return string Quoted string to be sent back to database - * - * @noinspection PhpUnusedParameterInspection */ function qStr($s, $magic_quotes=false) { @@ -1600,12 +1621,10 @@ class ADORecordset_oci8 extends ADORecordSet { /** @var resource Cursor reference */ var $_refcursor; - function __construct($queryID,$mode=false) + function __construct($queryID, $mode=false) { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } + parent::__construct($queryID, $mode); + switch ($mode) { case ADODB_FETCH_ASSOC: $this->fetchMode = OCI_ASSOC; @@ -1620,8 +1639,6 @@ class ADORecordset_oci8 extends ADORecordSet { break; } $this->fetchMode += OCI_RETURN_NULLS + OCI_RETURN_LOBS; - $this->adodbFetchMode = $mode; - $this->_queryID = $queryID; } /** @@ -1821,7 +1838,7 @@ class ADORecordset_oci8 extends ADORecordSet { * @param mixed $t * @param int $len [optional] Length of blobsize * @param bool $fieldobj [optional][discarded] - * @return str The metatype of the field + * @return string The metatype of the field */ function MetaType($t, $len=-1, $fieldobj=false) { diff --git a/drivers/adodb-odbc.inc.php b/drivers/adodb-odbc.inc.php index 56db8b0e..59909646 100644 --- a/drivers/adodb-odbc.inc.php +++ b/drivers/adodb-odbc.inc.php @@ -613,20 +613,13 @@ class ADORecordSet_odbc extends ADORecordSet { var $dataProvider = "odbc"; var $useFetchArray; - function __construct($id,$mode=false) + function __construct($queryID, $mode=false) { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - $this->fetchMode = $mode; - - $this->_queryID = $id; + parent::__construct($queryID, $mode); // the following is required for mysql odbc driver in 4.3.1 -- why? $this->EOF = false; $this->_currentRow = -1; - //parent::__construct($id); } diff --git a/drivers/adodb-odbtp.inc.php b/drivers/adodb-odbtp.inc.php index e3f81481..b4e12601 100644 --- a/drivers/adodb-odbtp.inc.php +++ b/drivers/adodb-odbtp.inc.php @@ -684,15 +684,6 @@ class ADORecordSet_odbtp extends ADORecordSet { var $databaseType = 'odbtp'; var $canSeek = true; - function __construct($queryID,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - $this->fetchMode = $mode; - parent::__construct($queryID); - } function _initrs() { diff --git a/drivers/adodb-oracle.inc.php b/drivers/adodb-oracle.inc.php index dc0462fe..5cd4bedf 100644 --- a/drivers/adodb-oracle.inc.php +++ b/drivers/adodb-oracle.inc.php @@ -223,16 +223,9 @@ class ADORecordset_oracle extends ADORecordSet { var $databaseType = "oracle"; var $bind = false; - function __construct($queryID,$mode=false) + function __construct($queryID, $mode=false) { - - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - $this->fetchMode = $mode; - - $this->_queryID = $queryID; + parent::__construct($queryID, $mode); $this->_inited = true; $this->fields = array(); @@ -249,9 +242,7 @@ class ADORecordset_oracle extends ADORecordSet { return $this->_queryID; } - - - /* Returns: an object containing field information. + /* Returns: an object containing field information. Get column information in the Recordset object. fetchField() can be used in order to obtain information about fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by fetchField() is retrieved. */ diff --git a/drivers/adodb-pdo.inc.php b/drivers/adodb-pdo.inc.php index d3ce12d0..bdc466dd 100644 --- a/drivers/adodb-pdo.inc.php +++ b/drivers/adodb-pdo.inc.php @@ -66,6 +66,10 @@ function adodb_pdo_type($t) class ADODB_pdo extends ADOConnection { + const BIND_USE_QUESTION_MARKS = 0; + const BIND_USE_NAMED_PARAMETERS = 1; + const BIND_USE_BOTH = 2; + var $databaseType = "pdo"; var $dataProvider = "pdo"; var $fmtDate = "'Y-m-d'"; @@ -100,6 +104,15 @@ class ADODB_pdo extends ADOConnection { */ public $pdoParameters = array(); + /* + * Set which style is used to bind parameters + * + * BIND_USE_QUESTION_MARKS = Use only question marks + * BIND_USE_NAMED_PARAMETERS = Use only named parameters + * BIND_USE_BOTH = Use both question marks and named parameters (Default) + */ + public $bindParameterStyle = self::BIND_USE_BOTH; + function _UpdatePDO() { $d = $this->_driver; @@ -592,11 +605,7 @@ class ADODB_pdo extends ADOConnection { $this->_driver->debug = $this->debug; } if ($inputarr) { - - /* - * inputarr must be numeric - */ - $inputarr = array_values($inputarr); + $inputarr = $this->conformToBindParameterStyle($stmt->queryString, $inputarr); $ok = $stmt->execute($inputarr); } else { @@ -666,6 +675,58 @@ class ADODB_pdo extends ADOConnection { return "'" . str_replace("'", $this->replaceQuote, $s) . "'"; } + /** + * Make bind parameters conform to settings. + * + * @param string $sql + * @param array $inputarr + * @return array + */ + private function conformToBindParameterStyle($sql, $inputarr) + { + switch ($this->bindParameterStyle) + { + case self::BIND_USE_QUESTION_MARKS: + default: + $inputarr = array_values($inputarr); + break; + + case self::BIND_USE_NAMED_PARAMETERS: + break; + + case self::BIND_USE_BOTH: + // inputarr must be numeric if SQL contains a question mark + if ($this->containsQuestionMarkPlaceholder($sql)) { + $inputarr = array_values($inputarr); + + if ($this->debug) { + ADOconnection::outp('improve the performance of this query by setting the bindParameterStyle to BIND_USE_QUESTION_MARKS'); + } + } + break; + } + + return $inputarr; + } + + /** + * Checks for the inclusion of a question mark placeholder. + * + * @param string $sql SQL string + * @return boolean Returns true if a question mark placeholder is included + */ + private function containsQuestionMarkPlaceholder($sql) + { + $pattern = '/(.\?(:?.|$))/'; + if (preg_match_all($pattern, $sql, $matches, PREG_SET_ORDER)) { + foreach ($matches as $match) { + if ($match[1] !== '`?`' && strpos($match[1], '??') === false) { + return true; + } + } + } + return false; + } } /** @@ -792,27 +853,25 @@ class ADORecordSet_pdo extends ADORecordSet { /** @var PDOStatement */ var $_queryID; - function __construct($id,$mode=false) + function __construct($queryID, $mode=false) { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - $this->adodbFetchMode = $mode; - switch($mode) { - case ADODB_FETCH_NUM: $mode = PDO::FETCH_NUM; break; - case ADODB_FETCH_ASSOC: $mode = PDO::FETCH_ASSOC; break; + parent::__construct($queryID, $mode); - case ADODB_FETCH_BOTH: - default: $mode = PDO::FETCH_BOTH; break; + switch($mode) { + case ADODB_FETCH_NUM: + $mode = PDO::FETCH_NUM; + break; + case ADODB_FETCH_ASSOC: + $mode = PDO::FETCH_ASSOC; + break; + case ADODB_FETCH_BOTH: + default: + $mode = PDO::FETCH_BOTH; + break; } $this->fetchMode = $mode; - - $this->_queryID = $id; - parent::__construct($id); } - function Init() { if ($this->_inited) { diff --git a/drivers/adodb-postgres64.inc.php b/drivers/adodb-postgres64.inc.php index 9bf9e713..9f02c5cd 100644 --- a/drivers/adodb-postgres64.inc.php +++ b/drivers/adodb-postgres64.inc.php @@ -26,6 +26,10 @@ class ADODB_postgres64 extends ADOConnection{ var $databaseType = 'postgres64'; var $dataProvider = 'postgres'; var $hasInsertID = true; + /** @var PgSql\Connection|resource|false Identifier for the native database connection */ + var $_connectionID = false; + /** @var PgSql\Connection|resource|false */ + var $_queryID; /** @var PgSql\Connection|resource|false */ var $_resultid = false; var $concat_operator='||'; @@ -85,7 +89,7 @@ class ADODB_postgres64 extends ADOConnection{ var $_pnum = 0; var $version; - var $_nestedSQL = false; + var $_nestedSQL = true; // The last (fmtTimeStamp is not entirely correct: // PostgreSQL also has support for time zones, @@ -117,9 +121,7 @@ class ADODB_postgres64 extends ADOConnection{ // If PHP has been compiled with PostgreSQL 7.3 or lower, then // server version is not set so we use pg_parameter_status() // which includes logic to obtain values server_version - 'version' => isset($version['server']) - ? $version['server'] - : pg_parameter_status($this->_connectionID, 'server_version'), + 'version' => $version['server'] ?? pg_parameter_status($this->_connectionID, 'server_version'), 'client' => $version['client'], 'description' => null, ); @@ -136,7 +138,15 @@ class ADODB_postgres64 extends ADOConnection{ return " coalesce($field, $ifNull) "; } - // get the last id - never tested + /** + * Get the last id - never tested. + * + * @param string $tablename + * @param string $fieldname + * @return false|mixed + * + * @noinspection PhpUnused + */ function pg_insert_id($tablename,$fieldname) { $result=pg_query($this->_connectionID, 'SELECT last_value FROM '. $tablename .'_'. $fieldname .'_seq'); @@ -158,7 +168,9 @@ class ADODB_postgres64 extends ADOConnection{ */ protected function _insertID($table = '', $column = '') { - if ($this->_resultid === false) return false; + if ($this->_resultid === false) { + return false; + } $oid = pg_last_oid($this->_resultid); // to really return the id, we need the table and column-name, else we can only return the oid != id return empty($table) || empty($column) ? $oid : $this->GetOne("SELECT $column FROM $table WHERE oid=".(int)$oid); @@ -166,7 +178,9 @@ class ADODB_postgres64 extends ADOConnection{ function _affectedrows() { - if ($this->_resultid === false) return false; + if ($this->_resultid === false) { + return false; + } return pg_affected_rows($this->_resultid); } @@ -181,13 +195,14 @@ class ADODB_postgres64 extends ADOConnection{ return pg_query($this->_connectionID, 'begin '.$this->_transmode); } - function RowLock($tables,$where,$col='1 as adodbignore') + function RowLock($table, $where, $col='1 as adodbignore') { - if (!$this->transCnt) $this->BeginTrans(); - return $this->GetOne("select $col from $tables where $where for update"); + if (!$this->transCnt) { + $this->BeginTrans(); + } + return $this->GetOne("select $col from $table where $where for update"); } - // returns true/false. function CommitTrans($ok=true) { if ($this->transOff) return true; @@ -197,7 +212,6 @@ class ADODB_postgres64 extends ADOConnection{ return pg_query($this->_connectionID, 'commit'); } - // returns true/false function RollbackTrans() { if ($this->transOff) return true; @@ -264,8 +278,6 @@ class ADODB_postgres64 extends ADOConnection{ } } - - // Format date column in sql string given an input format that understands Y M D function SQLDate($fmt, $col=false) { if (!$col) $col = $this->sysTimeStamp; @@ -345,15 +357,24 @@ class ADODB_postgres64 extends ADOConnection{ - /* - * Load a Large Object from a file - * - the procedure stores the object id in the table and imports the object using - * postgres proprietary blob handling routines - * - * contributed by Mattia Rossi mattia@technologist.com - * modified for safe mode by juraj chlebec - */ - function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB') + /** + * Update a BLOB from a file. + * + * The procedure stores the object id in the table and imports the object using + * postgres proprietary blob handling routines. + * + * Usage example: + * $conn->updateBlobFile('table', 'blob_col', '/path/to/file', 'id=1'); + * + * @param string $table + * @param string $column + * @param string $path Filename containing blob data + * @param mixed $where {@see updateBlob()} + * @param string $blobtype supports 'BLOB' and 'CLOB' + * + * @return bool success + */ + function updateBlobFile($table,$column,$path,$where,$blobtype='BLOB') { pg_query($this->_connectionID, 'begin'); @@ -369,24 +390,25 @@ class ADODB_postgres64 extends ADOConnection{ // $oid = pg_lo_import ($path); pg_query($this->_connectionID, 'commit'); $rs = ADOConnection::UpdateBlob($table,$column,$oid,$where,$blobtype); - $rez = !empty($rs); - return $rez; + return !empty($rs); } - /* - * Deletes/Unlinks a Blob from the database, otherwise it - * will be left behind - * - * Returns TRUE on success or FALSE on failure. - * - * contributed by Todd Rogers todd#windfox.net - */ - function BlobDelete( $blob ) + /** + * Deletes/Unlinks a Blob from the database, otherwise it will be left behind. + * + * contributed by Todd Rogers todd#windfox.net + * + * @param mixed $blob + * @return bool True on success, false on failure. + * + * @noinspection PhpUnused + */ + function BlobDelete($blob) { pg_query($this->_connectionID, 'begin'); $result = @pg_lo_unlink($this->_connectionID, $blob); pg_query($this->_connectionID, 'commit'); - return( $result ); + return $result; } /* @@ -398,19 +420,21 @@ class ADODB_postgres64 extends ADOConnection{ return is_numeric($oid); } - /* - * If an OID is detected, then we use pg_lo_* to open the oid file and read the - * real blob from the db using the oid supplied as a parameter. If you are storing - * blobs using bytea, we autodetect and process it so this function is not needed. - * - * contributed by Mattia Rossi mattia@technologist.com - * - * see http://www.postgresql.org/idocs/index.php?largeobjects.html - * - * Since adodb 4.54, this returns the blob, instead of sending it to stdout. Also - * added maxsize parameter, which defaults to $db->maxblobsize if not defined. - */ - function BlobDecode($blob,$maxsize=false,$hastrans=true) + /** + * If an OID is detected, then we use pg_lo_* to open the oid file and read the + * real blob from the db using the oid supplied as a parameter. If you are storing + * blobs using bytea, we autodetect and process it so this function is not needed. + * + * Contributed by Mattia Rossi mattia@technologist.com + * + * @link https://www.postgresql.org/docs/current/largeobjects.html + * + * @param mixed $blob + * @param int|false $maxsize Defaults to $db->maxblobsize if false + * @param bool $hastrans + * @return string|false The blob + */ + function BlobDecode($blob, $maxsize=false, $hastrans=true) { if (!$this->GuessOID($blob)) return $blob; @@ -430,7 +454,7 @@ class ADODB_postgres64 extends ADOConnection{ /** * Encode binary value prior to DB storage. * - * See https://www.postgresql.org/docs/current/static/datatype-binary.html + * @link https://www.postgresql.org/docs/current/static/datatype-binary.html * * NOTE: SQL string literals (input strings) must be preceded with two * backslashes due to the fact that they must pass through two parsers in @@ -491,7 +515,6 @@ class ADODB_postgres64 extends ADOConnection{ global $ADODB_FETCH_MODE; $schema = false; - $false = false; $this->_findschema($table,$schema); if ($normalize) $table = strtolower($table); @@ -505,7 +528,7 @@ class ADODB_postgres64 extends ADOConnection{ $ADODB_FETCH_MODE = $save; if ($rs === false) { - return $false; + return false; } if (!empty($this->metaKeySQL)) { // If we want the primary keys, we have to issue a separate query @@ -523,6 +546,8 @@ class ADODB_postgres64 extends ADOConnection{ $rskey->Close(); unset($rskey); + } else { + $keys = []; } $rsdefa = array(); @@ -575,28 +600,29 @@ class ADODB_postgres64 extends ADOConnection{ //Freek $fld->not_null = $rs->fields[4] == 't'; - // Freek if (is_array($keys)) { foreach($keys as $key) { - if ($fld->name == $key['column_name'] AND $key['primary_key'] == 't') + if ($fld->name == $key['column_name'] && $key['primary_key'] == 't') { $fld->primary_key = true; - if ($fld->name == $key['column_name'] AND $key['unique_key'] == 't') + } + if ($fld->name == $key['column_name'] && $key['unique_key'] == 't') { $fld->unique = true; // What name is more compatible? + } } } - if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; - else $retarr[($normalize) ? strtoupper($fld->name) : $fld->name] = $fld; + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) { + $retarr[] = $fld; + } + else { + $retarr[($normalize) ? strtoupper($fld->name) : $fld->name] = $fld; + } $rs->MoveNext(); } $rs->Close(); - if (empty($retarr)) - return $false; - else - return $retarr; - + return $retarr ?: false; } function param($name, $type='C') @@ -640,7 +666,7 @@ class ADODB_postgres64 extends ADOConnection{ WHERE (c2.relname=\'%s\' or c2.relname=lower(\'%s\'))'; } - if ($primary == FALSE) { + if (!$primary) { $sql .= ' AND i.indisprimary=false;'; } @@ -657,8 +683,7 @@ class ADODB_postgres64 extends ADOConnection{ $ADODB_FETCH_MODE = $save; if (!is_object($rs)) { - $false = false; - return $false; + return false; } // Get column names indexed by attnum so we can lookup the index key @@ -749,22 +774,6 @@ class ADODB_postgres64 extends ADOConnection{ if ($this->_connectionID === false) return false; $this->Execute("set datestyle='ISO'"); - $info = $this->ServerInfo(false); - - if (version_compare($info['version'], '7.1', '>=')) { - $this->_nestedSQL = true; - } - - # PostgreSQL 9.0 changed the default output for bytea from 'escape' to 'hex' - # PHP does not handle 'hex' properly ('x74657374' is returned as 't657374') - # https://bugs.php.net/bug.php?id=59831 states this is in fact not a bug, - # so we manually set bytea_output - if (version_compare($info['version'], '9.0', '>=') - && version_compare($info['client'], '9.2', '<') - ) { - $this->Execute('set bytea_output=escape'); - } - return true; } @@ -911,17 +920,17 @@ class ADODB_postgres64 extends ADOConnection{ } - /* - * Maximum size of C field - */ + /** + * @return int Maximum size of C field + */ function CharMax() { return 1000000000; // should be 1 Gb? } - /* - * Maximum size of X field - */ + /** + * @return int Maximum size of X field + */ function TextMax() { return 1000000000; // should be 1 Gb? @@ -941,23 +950,21 @@ class ADORecordSet_postgres64 extends ADORecordSet{ function __construct($queryID, $mode=false) { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - switch ($mode) - { - case ADODB_FETCH_NUM: $this->fetchMode = PGSQL_NUM; break; - case ADODB_FETCH_ASSOC:$this->fetchMode = PGSQL_ASSOC; break; + parent::__construct($queryID, $mode); - case ADODB_FETCH_DEFAULT: - case ADODB_FETCH_BOTH: - default: $this->fetchMode = PGSQL_BOTH; break; + switch ($mode) { + case ADODB_FETCH_NUM: + $this->fetchMode = PGSQL_NUM; + break; + case ADODB_FETCH_ASSOC: + $this->fetchMode = PGSQL_ASSOC; + break; + case ADODB_FETCH_DEFAULT: + case ADODB_FETCH_BOTH: + default: + $this->fetchMode = PGSQL_BOTH; + break; } - $this->adodbFetchMode = $mode; - - // Parent's constructor - parent::__construct($queryID); } function GetRowAssoc($upper = ADODB_ASSOC_CASE) @@ -965,8 +972,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{ if ($this->fetchMode == PGSQL_ASSOC && $upper == ADODB_ASSOC_CASE_LOWER) { return $this->fields; } - $row = ADORecordSet::GetRowAssoc($upper); - return $row; + return ADORecordSet::GetRowAssoc($upper); } function _initRS() @@ -978,7 +984,6 @@ class ADORecordSet_postgres64 extends ADORecordSet{ // cache types for blob decode check // apparently pg_field_type actually performs an sql query on the database to get the type. - if (empty($this->connection->noBlobs)) for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { if (pg_field_type($qid,$i) == 'bytea') { $this->_blobArr[$i] = pg_field_name($qid,$i); @@ -1045,7 +1050,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{ } } if ($this->fetchMode == PGSQL_ASSOC || $this->fetchMode == PGSQL_BOTH) { - foreach($this->_blobArr as $k => $v) { + foreach($this->_blobArr as $v) { $this->fields[$v] = ADORecordSet_postgres64::_decode($this->fields[$v]); } } @@ -1086,7 +1091,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{ return pg_free_result($this->_queryID); } - function MetaType($t,$len=-1,$fieldobj=false) + function MetaType($t,$len=-1, $fieldObj=false) { if (is_object($t)) { $fieldobj = $t; @@ -1096,71 +1101,81 @@ class ADORecordSet_postgres64 extends ADORecordSet{ $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 'MONEY': // stupid, postgres expects money to be a string - case 'INTERVAL': - case 'CHAR': - case 'CHARACTER': - case 'VARCHAR': - case 'NAME': - case 'BPCHAR': - case '_VARCHAR': - case 'CIDR': - case 'INET': - case 'MACADDR': - case 'UUID': - if ($len <= $this->blobSize) return 'C'; - - case 'TEXT': - return 'X'; + case 'MONEY': // stupid, postgres expects money to be a string + case 'INTERVAL': + case 'CHAR': + case 'CHARACTER': + case 'VARCHAR': + case 'NAME': + case 'BPCHAR': + case '_VARCHAR': + case 'CIDR': + case 'INET': + case 'MACADDR': + /** @noinspection PhpMissingBreakStatementInspection */ + case 'UUID': + if ($len <= $this->blobSize) { + return 'C'; + } + // Fall-through - case 'IMAGE': // user defined type - case 'BLOB': // user defined type - case 'BIT': // This is a bit string, not a single bit, so don't return 'L' - case 'VARBIT': - case 'BYTEA': - return 'B'; + case 'TEXT': + return 'X'; - case 'BOOL': - case 'BOOLEAN': - return 'L'; + case 'IMAGE': // user defined type + case 'BLOB': // user defined type + case 'BIT': // This is a bit string, not a single bit, so don't return 'L' + case 'VARBIT': + case 'BYTEA': + return 'B'; - case 'DATE': - return 'D'; + case 'BOOL': + case 'BOOLEAN': + return 'L'; + case 'DATE': + return 'D'; - case 'TIMESTAMP WITHOUT TIME ZONE': - case 'TIME': - case 'DATETIME': - case 'TIMESTAMP': - case 'TIMESTAMPTZ': - return 'T'; + case 'TIMESTAMP WITHOUT TIME ZONE': + case 'TIME': + case 'DATETIME': + case 'TIMESTAMP': + case 'TIMESTAMPTZ': + return 'T'; - case 'SMALLINT': - case 'BIGINT': - case 'INTEGER': - case 'INT8': - case 'INT4': - case 'INT2': - if (isset($fieldobj) && - empty($fieldobj->primary_key) && (!$this->connection->uniqueIisR || empty($fieldobj->unique))) return 'I'; + case 'SMALLINT': + case 'BIGINT': + case 'INTEGER': + case 'INT8': + case 'INT4': + /** @noinspection PhpMissingBreakStatementInspection */ + case 'INT2': + if (isset($fieldobj) + && empty($fieldobj->primary_key) + && (!$this->connection->uniqueIisR || empty($fieldobj->unique)) + ) { + return 'I'; + } + // Fall-through - case 'OID': - case 'SERIAL': - return 'R'; + case 'OID': + case 'SERIAL': + return 'R'; - case 'NUMERIC': - case 'DECIMAL': - case 'FLOAT4': - case 'FLOAT8': - return 'N'; + case 'NUMERIC': + case 'DECIMAL': + case 'FLOAT4': + case 'FLOAT8': + return 'N'; - default: - return ADODB_DEFAULT_METATYPE; - } + default: + return ADODB_DEFAULT_METATYPE; + } } } diff --git a/drivers/adodb-sqlite.inc.php b/drivers/adodb-sqlite.inc.php index d41829c0..d4cf19be 100644 --- a/drivers/adodb-sqlite.inc.php +++ b/drivers/adodb-sqlite.inc.php @@ -425,14 +425,11 @@ class ADORecordset_sqlite extends ADORecordSet { var $databaseType = "sqlite"; var $bind = false; - function __construct($queryID,$mode=false) + function __construct($queryID, $mode=false) { + parent::__construct($queryID, $mode); - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - switch($mode) { + switch ($mode) { case ADODB_FETCH_NUM: $this->fetchMode = SQLITE_NUM; break; @@ -443,9 +440,6 @@ class ADORecordset_sqlite extends ADORecordSet { $this->fetchMode = SQLITE_BOTH; break; } - $this->adodbFetchMode = $mode; - - $this->_queryID = $queryID; $this->_inited = true; $this->fields = array(); @@ -462,7 +456,6 @@ class ADORecordset_sqlite extends ADORecordSet { return $this->_queryID; } - function FetchField($fieldOffset = -1) { $fld = new ADOFieldObject; diff --git a/drivers/adodb-sqlite3.inc.php b/drivers/adodb-sqlite3.inc.php index 7623a3c8..822a649d 100644 --- a/drivers/adodb-sqlite3.inc.php +++ b/drivers/adodb-sqlite3.inc.php @@ -719,12 +719,9 @@ class ADORecordset_sqlite3 extends ADORecordSet { var $_queryID; /** @noinspection PhpMissingParentConstructorInspection */ - function __construct($queryID,$mode=false) + function __construct($queryID, $mode=false) { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } + parent::__construct($queryID, $mode); switch($mode) { case ADODB_FETCH_NUM: $this->fetchMode = SQLITE3_NUM; @@ -736,9 +733,6 @@ class ADORecordset_sqlite3 extends ADORecordSet { $this->fetchMode = SQLITE3_BOTH; break; } - $this->adodbFetchMode = $mode; - - $this->_queryID = $queryID; $this->_inited = true; $this->fields = array(); @@ -755,7 +749,6 @@ class ADORecordset_sqlite3 extends ADORecordSet { return $this->_queryID; } - function FetchField($fieldOffset = -1) { $fld = new ADOFieldObject; diff --git a/drivers/adodb-sybase.inc.php b/drivers/adodb-sybase.inc.php index 79fb82e8..f6c8f58c 100644 --- a/drivers/adodb-sybase.inc.php +++ b/drivers/adodb-sybase.inc.php @@ -315,15 +315,15 @@ class ADORecordset_sybase extends ADORecordSet { // _mths works only in non-localised system var $_mths = array('JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12); - function __construct($id,$mode=false) + function __construct($queryID, $mode=false) { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; + parent::__construct($queryID, $mode); + + if (!$mode) { + $this->fetchMode = ADODB_FETCH_ASSOC; + } else { + $this->fetchMode = $mode; } - if (!$mode) $this->fetchMode = ADODB_FETCH_ASSOC; - else $this->fetchMode = $mode; - parent::__construct($id); } /* Returns: an object containing field information. |
