Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions ToolkitApi/Odbcsupp.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public function connect($database, $user, $password, $options = null)
$conn = odbc_connect($database, $user, $password);
}

if (is_resource($conn)) {
if ((version_compare(PHP_VERSION, '8.4.0', '<') && is_resource($conn)) ||
(version_compare(PHP_VERSION, '8.4.0', '>=') && $conn instanceof \Odbc\Connection)) {
return $conn;
}
}
Expand All @@ -51,7 +52,8 @@ public function connect($database, $user, $password, $options = null)
*/
public function disconnect($conn)
{
if (is_resource($conn)) {
if ((version_compare(PHP_VERSION, '8.4.0', '<') && is_resource($conn)) ||
(version_compare(PHP_VERSION, '8.4.0', '>=') && $conn instanceof \Odbc\Connection)) {
odbc_close($conn);
}
}
Expand Down Expand Up @@ -168,7 +170,8 @@ public function executeQuery($conn, $stmt)
$txt = array();
$crsr = odbc_exec($conn, $stmt);

if (is_resource($crsr)) {
if ((version_compare(PHP_VERSION, '8.4.0', '<') && is_resource($crsr)) ||
(version_compare(PHP_VERSION, '8.4.0', '>=') && $crsr instanceof \Odbc\Result)) {
while (odbc_fetch_row($crsr)) {
$row = odbc_result($crsr, 1);

Expand Down
3 changes: 2 additions & 1 deletion ToolkitApi/Toolkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ public function __construct($databaseNameOrResource, $userOrI5NamingFlag = '0',
$this->debugLog("Created a new db connection in $durationCreate seconds.");
}

if (!$conn) {
if ((version_compare(PHP_VERSION, '8.4.0', '<') && !is_resource($conn)) ||
(version_compare(PHP_VERSION, '8.4.0', '>=') && !($conn instanceof \Odbc\Connection))) {
// Note: SQLState 08001 (with or without SQLCODE=-30082) usually means invalid user or password. This is true for DB2 and ODBC.
$sqlState = $transport->getErrorCode();
$this->error = $transport->getErrorMsg();
Expand Down