v5:userguide:debug
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
v5:userguide:debug [2022/08/21 19:11] – Updated the special options into the page mnewnham | v5:userguide:debug [2024/01/09 11:20] (current) – [Description] link to Logging page dregad | ||
---|---|---|---|
Line 8: | Line 8: | ||
===== Description ===== | ===== Description ===== | ||
- | Enabling debug mode makes the driver return | + | |
+ | Enabling debug mode makes the driver return debugging information from both ADOdb and the PHP driver itself. | ||
+ | |||
+ | The output | ||
+ | It is suitable for viewing in a browser | ||
+ | |||
+ | See [[v5: | ||
===== 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 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. | ||
+ | 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 produces no output and simply returns false. | ||
<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-> | ||
- | /* | + | |
- | * Invalid syntax in select statment | + | $recordSet = $conn-> |
- | */ | + | |
- | $recordSet = $conn-> | + | |
</ | </ | ||
+ | |||
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; | ||
+ | } | ||
</ | </ | ||
- | By default, the parameters passed to each SQL statement to be executed are compressed into a set of key=> | ||
- | ===== 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 ===== | ===== Limitations ===== | ||
v5/userguide/debug.1661101874.txt.gz · Last modified: 2022/08/21 19:11 by mnewnham