Subject | RE: [firebird-php] echo resultin sql |
---|---|
Author | Nigel Weeks |
Post date | 2005-08-11T06:25:42Z |
> I have been struggling to echo out the resulting sql to whatThis is perfectly correct. The variable you populate with an ibase_prepare
> it is inserting how do i echo out the sql string.
>
> $this->insertNewItem is a prepared sql statement and
> obviously i am passing values in the the statement below.
>
> ibase_execute($this->insertNewItem,
> $this->getInventoryNo($csvLine[0]),
> $this->branchNo, $csvLine[114], $csvLine[115]);
>
> when i try to echo $this->insertNewItem gives me resource id
> 25 this has been bugging me sometime time now :(
>
contans a resource ID. That's the point. It saves the database re-preparing
the query every time.
If you want to know what your execute statement is about to do, fake it.
You have the values, just echo them.
If you're completely lost by the above, here's the different between the two
methods:
// Instant prepare method
<?php
$conn = ibase_connect("server:/path/to/db.fdb","sysdba","masterkey");
$sql = "SELECT henry, jones FROM BLAH";
// $sql now contains the query string
$rec = ibase_query($sql);
// $rec now contains a result set pointer
$obj = ibase_fetch_object($rec);
// $obj now contains an object of values from your query
echo $obj->HENRY.$obj->JONES;
// We just echoed out the contents of the two values
?>
// Prepare/Execute Method
<?php
$conn = ibase_connect("server:/path/to/db.fdb","sysdba","masterkey");
$prep = ibase_prepare("SELECT henry, jones FROM BLAH");
// $prep now contains the resource ID of the prepared statement, NOT the
query string
$obj = ibase_execute($prep);
// $obj now contains a result set pointer
$obj = ibase_fetch_object($rec);
// $obj now contains an object of values from your query
echo $obj->HENRY.$obj->JONES;
// We just echoed out the contents of the two values
?>