ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:userguide:debug

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
v5:userguide:debug [2018/07/02 13:06] – prefer functions start lowercase (#430) peterddv5:userguide:debug [2023/04/08 12:39] – [Usage] revised example following 5.23 refactoring of _adodb_debug_execute(). Note: removed paragraph on STDERR output, I don't think we actually do that anymore dregad
Line 4: Line 4:
 <WRAP right box> <WRAP right box>
 == Syntax == == Syntax ==
-  $connection->debug = boolean;+  $connection->debug = boolean|int;
 </WRAP> </WRAP>
  
Line 10: Line 10:
 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. Information is displayed on both standard output (STDOUT) and standard error (STDERR) channels. 
 ===== 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 '/dev/access/adodb-master/adodb.inc.php'; +include 'adodb.inc.php'; 
-$conn = newAdoConnection('access'); +$conn = newAdoConnection('mysqli'); 
-$conn->connect('northwind');+$conn->connect($host, $user, $pass, 'database');
 $conn->debug = true; $conn->debug = true;
-/* +$recordSet = $conn->execute('SELECT FROM product');
-* Invalid syntax in select statment +
-*/ +
-$recordSet = $conn->execute('select from product');+
 </code> </code>
 +
 The information returned on STDOUT is: The information returned on STDOUT is:
 <code> <code>
------<hr> +------------------------------------------------------------------------------ 
-(access)select from product  +mysqliSELECT FROM product 
-    +------------------------------------------------------------------------------ 
------<hr>+Query: select * from product failed. Table 'database.product' doesn't exist 
 +1146: Table 'database.product' doesn't exist
  
-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::_Execute(SELECT * FROM product) in .../drivers/adodb-mysqli.inc.php line 1091 
-name is spelled correctly., SQL state S0002 in SQLExecDirect in /ADOdb/drivers/adodb-odbc.inc.php  + 1. ADODB_mysqli::execute(SELECT FROM product) in .../test.php line 36
-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+
 </code>  </code> 
-  + 
-Information on STDERR +By default, the parameters passed to the query are compressed into a set of //key => value// pairs.  
-<code> +This information is printed after the SQL statement, using a ''<code>'' tag. Styling can be applied using CSS, see [[#formatting|Formatting section below]]. 
-PHP Warning:  odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access DriverThe Microsoft Access + 
-database engine cannot find the input table or query 'product'. Make sure it exists and that its  +===== Special Options ===== 
-name is spelled correctly.SQL state S0002 in SQLExecDirect in C:\ADOdb\drivers\adodb-odbc.inc.php on line 540 +There are 3 non-boolean switches that, if set, will vary some of the output produced 
-</code>+ 
 +^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 browserthen 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 **//if the execution succeeds//**, reducing the amount of output to STDOUT |
 ===== Limitations ===== ===== Limitations =====
  
v5/userguide/debug.txt · Last modified: 2024/01/09 11:20 by dregad