v5:userguide:debug
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
reference:debug [2015/11/23 00:37] – created mnewnham | v5:userguide:debug [2024/01/09 11:03] – Add comments in sample code block dregad | ||
---|---|---|---|
Line 4: | Line 4: | ||
<WRAP right box> | <WRAP right box> | ||
== Syntax == | == Syntax == | ||
- | $connection-> | + | $connection-> |
</ | </ | ||
===== Description ===== | ===== 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. | + | |
+ | Enabling debug mode makes the driver return copious amounts of debugging information from both ADOdb and the PHP driver itself. | ||
===== Usage ===== | ===== Usage ===== | ||
- | The debug option can be enabled and disabled at any time, to debug portions of a program. The earliest it can be enabled | + | |
+ | The //debug// option can be enabled and disabled at any time, to debug portions of a program. | ||
+ | The earliest it can be set 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 | ||
<code php> | <code php> | ||
- | include '/ | + | include ' |
- | $conn = newAdoConnection(' | + | $conn = newAdoConnection(' |
- | $conn-> | + | |
+ | # Here is the earliest point where Debug Mode can be set | ||
+ | |||
+ | $conn-> | ||
+ | |||
+ | # Enable Debug mode | ||
$conn-> | $conn-> | ||
- | $recordSet = $conn->Execute('select | + | |
+ | $recordSet = $conn->execute('SELECT | ||
</ | </ | ||
+ | |||
The information returned on STDOUT is: | The information returned on STDOUT is: | ||
< | < | ||
- | -----<hr> | + | ------------------------------------------------------------------------------ |
- | (access): select | + | mysqli: SELECT |
- | + | ------------------------------------------------------------------------------ | |
- | -----<hr> | + | Query: select * from product failed. Table ' |
+ | 1146: Table ' | ||
- | Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] The Microsoft Access | + | Call stack (most recent call first): |
- | database engine cannot find the input table or query 'product'. Make sure it exists and that its | + | 2. ADOConnection:: |
- | name is spelled correctly., SQL state S0002 in SQLExecDirect in /ADOdb/ | + | 1. ADODB_mysqli::execute(SELECT |
- | on line 540 | + | |
- | S0002: [Microsoft][ODBC Microsoft Access Driver] The Microsoft Access database engine cannot | + | |
- | find the input table or query ' | + | |
- | ADOConnection._Execute(select | + | |
- | ADOConnection.Execute(select * from product)% line 6, file: C: | + | |
</ | </ | ||
- | + | ||
- | Information on STDERR | + | By default, the parameters passed to the query are compressed into a set of //key => value// pairs. |
- | < | + | This information is printed after the SQL statement, using a '' |
- | PHP Warning: | + | |
- | database engine cannot find the input table or query ' | + | ==== Possible values ==== |
- | name is spelled correctly., SQL state S0002 in SQLExecDirect | + | |
+ | In addition to the standard '' | ||
+ | |||
+ | ^ Value ^ Description | ||
+ | | False | Debug mode disabled | ||
+ | | True | Standard mode, prints executed | ||
+ | | -1 | Same as Standard mode, but with the line separators around the SQL statements suppressed. | ||
+ | | 99 | Prints a Backtrace after every query execution, **even if the execution is successful**. | | ||
+ | | -99 | Debug information | ||
+ | |||
+ | |||
+ | ===== Formatting ===== | ||
+ | |||
+ | Starting with ADOdb 5.23.0, debug output is printed with HTML markup and styled with CSS classes. This can be leveraged to improve display of various elements. | ||
+ | The output' | ||
+ | |||
+ | * Wrapper '' | ||
+ | * **SQL statement** '' | ||
+ | * Table with 2 columns (column 1 has '' | ||
+ | * Row 1 with the query in a '' | ||
+ | * Optional row 2 with the parameters | ||
+ | * **Error message** '' | ||
+ | * Code execution **backtrace** '' | ||
+ | |||
+ | Here is how the output looks like with the basic stylesheet below | ||
+ | |||
+ | {{ :v5: | ||
+ | |||
+ | <code css> | ||
+ | .adodb-debug-sql code { | ||
+ | font-size: large; | ||
+ | } | ||
+ | .adodb-debug-errmsg { | ||
+ | font-weight: | ||
+ | color: red; | ||
+ | } | ||
+ | .adodb-debug-trace table { | ||
+ | border-spacing: | ||
+ | border: 1px solid; | ||
+ | } | ||
+ | .adodb-debug-trace thead { | ||
+ | background-color: | ||
+ | } | ||
+ | .adodb-debug-trace th, .adodb-debug-trace td { | ||
+ | border: 1px solid; | ||
+ | padding: 2px 6px; | ||
+ | } | ||
</ | </ | ||
+ | |||
+ | |||
===== Limitations ===== | ===== Limitations ===== | ||
* Historically, | * Historically, | ||
* Some drivers, the SQL server driver in particular, produce overwhelming volumes of debugging information. | * Some drivers, the SQL server driver in particular, produce overwhelming volumes of debugging information. | ||
+ | |||
+ | {{tag> |
v5/userguide/debug.txt · Last modified: 2024/01/09 11:20 by dregad