This is an old revision of the document!
Debug Mode
Syntax
$connection->debug = boolean|int;
Description
Enabling debug mode makes the driver return copious amounts of debugging information from both ADOdb and the PHP driver itself. Information is displayed on both standard output (STDOUT) and standard error (STDERR) channels.
Usage
The debug option can be enabled and disabled at any time, to debug portions of a program. The earliest it can be enabled is after the inclusion of the driver, and before the connection. In the following example, the table name is spelled incorrectly (it should be products). When run without debugging, the execution of the statement simply returns false.
include '/dev/access/adodb-master/adodb.inc.php'; $conn = newAdoConnection('access'); $conn->connect('northwind'); $conn->debug = true; /* * Invalid syntax in select statment */ $recordSet = $conn->execute('select * from product');
The information returned on STDOUT is:
-----<hr> (access): select * from product -----<hr> Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] The Microsoft Access database engine cannot find the input table or query 'product'. Make sure it exists and that its name is spelled correctly., SQL state S0002 in SQLExecDirect in /ADOdb/drivers/adodb-odbc.inc.php on line 540 S0002: [Microsoft][ODBC Microsoft Access Driver] The Microsoft Access database engine cannot find the input table or query 'product'. Make sure it exists and that its name is spelled correctly. ADOConnection._Execute(select * from product, false)% line 1163, file: C:\dev\access\ADOdb-master\adodb.inc.php ADOConnection.Execute(select * from product)% line 6, file: C:\temp\access\test3.php
Information on STDERR
PHP Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] The Microsoft Access database engine cannot find the input table or query 'product'. Make sure it exists and that its name is spelled correctly., SQL state S0002 in SQLExecDirect in C:\ADOdb\drivers\adodb-odbc.inc.php on line 540
By default, the parameters passed to each SQL statement to be executed are compressed into a set of key⇒value pairs. This information is printed using the <code> tag if sent to a browser after the print of the SQL statement. An additional class “adodb-debug” can be used to apply styling to the statement.
Special Options
There are 3 non-boolean switches that, if set, will vary some of the output produce
Value | Description |
---|---|
99 | If set, then the results of a debug_backtrace will be appended to every database execution, even if the execution is successful |
-1 | If set, and the code is being run in a browser, then the line separators around the statement are suppressed. This option has no effect when the code is run in a CLI environment. |
-99 | If set, then the SQL statement print is suppressed, reducing the amount of output to STDOUT |
Limitations
- Historically, the output messages were coded to be sent to a web page and some contain formatting that may make the messages more difficult to read.
- Some drivers, the SQL server driver in particular, produce overwhelming volumes of debugging information.