Print evaluated query string using ADODB/PHP

Snippet

After a parameterized querystring has been evaluated, but before the query has been run, print out the query string, using ADODB PHP library.

<?php
 
/*
 * include the ADODB library
 */
include('adodb.inc.php');
 
/*
 * Make a new connection to DB
 */
$mydb = &ADONewConnection('access');     
$mydb->PConnect('northwind');  
 
/*
 * filter input
 */
$shipto = $conn->qstr("John's Old Shoppe");
 
/*
 * generate SQL
 */
$sql = "insert into orders (customerID,EmployeeID,OrderDate,ShipName) ";
$sql .= "values ('ANATR',2,".$mydb->FormatDate(time()).",?)";
 
/*
 *
 *
 * PRINT THE SQL BEFORE EXECUTING THE QUERY
 *
 *
 */
$mydb->debug = true;
 
if ($mydb->Execute($sql, $shipto) === false) print 'error inserting';
 
?>

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.