PHP Fatal error: Uncaught Error: Object of class PDO could not be converted to string in /QOpenSys/pkgs/lib/php/ToolkitApi/Toolkit.php:204
Stack trace:
#0 /QOpenSys/pkgs/lib/php/ToolkitApi/ToolkitService.php(25): ToolkitApi\Toolkit->__construct(Object(PDO), 1, '', 'pdo', Array)
#1 /www/phprpmodbc/htdocs/toolkit/samples/connect_pdo_odbc.php(39): ToolkitService::getInstance(Object(PDO), 1, '', 'pdo')
#2 {main}
thrown in /QOpenSys/pkgs/lib/php/ToolkitApi/Toolkit.php on line 204
Fatal error: Uncaught Error: Object of class PDO could not be converted to string in /QOpenSys/pkgs/lib/php/ToolkitApi/Toolkit.php on line 204
This error can be avoided by specifying 'debug' => true in the setOptions() method rather than in toolkit.ini, because setOptions() gets called after the connection is established, and thus doesn't attempt to log information about the PDO object.
Let's correct the underlying issue in the __construct() method, though.
When a PDO connection is used, as in our sample (https://github.com/zendtech/IbmiToolkit/blob/master/samples/connect_pdo_odbc.php), and toolkit.ini specifies
debug = true
, the debugging code causes an error when treating the PDO object as a string at: https://github.com/zendtech/IbmiToolkit/blob/0422b499ec9610c7aa9708cffb22f40469636e11/ToolkitApi/Toolkit.php#L204This error can be avoided by specifying 'debug' => true in the setOptions() method rather than in toolkit.ini, because setOptions() gets called after the connection is established, and thus doesn't attempt to log information about the PDO object.
Let's correct the underlying issue in the __construct() method, though.