Database Reference
In-Depth Information
{
$pad = $row['PAD'];
}
oci_free_statement
($statement);
}
Since full control over the cursors is available, it's possible to implement test case 3 as well. The following
code snippet is an example. Notice how the functions that prepare (
oci_parse
and
oci_bind_by_name
) and close
(
oci_free_statement
) the cursor are placed outside the loop to avoid unnecessary soft parses.
$sql = "SELECT pad FROM t WHERE val = :val";
$statement =
oci_parse
($connection, $sql);
oci_bind_by_name
($statement, ":val", $i, -1, SQLT_INT);
for ($i = 1; $i <= 10000; $i++)
{
oci_execute($statement, OCI_NO_AUTO_COMMIT);
if ($row = oci_fetch_assoc($statement))
{
$pad = $row['PAD'];
}
}
oci_free_statement
($statement);
PHP not only enables full control of the cursors but, as of OCI8 1.1, also supports client-side statement caching.
To control it, the
oci8.statement_cache_size
directive is available. If it's set to 0, client-side statement caching is
disabled. Values higher than 0 enable client-side caching, and specify how many cursors are cached. The default value
is 20, enabling client-side caching for up to 20 cursors. To change the value, add a line like the following to the
php.ini
configuration file:
oci8.statement_cache_size = 50
The PHP code used for the examples in this section comes from excerpts from the
ParsingTest1.php
,
ParsingTest2.php
, and
ParsingTest3.php
files. Those files implement test cases 1, 2, and 3, respectively.
On to Chapter 13
This chapter describes how to identify, solve, and work around parsing problems. The key message is that by knowing
how your application works and the possibilities given by the used application programming interface, you should be
able to avoid parsing problems by writing efficient code during the development stage.
Since in the life cycle of a cursor the execution phase follows the parsing of the SQL statement and the binding of
variables, it's necessary to know the different techniques used by the database engine to access data. The next chapter
discusses this, and describes how to take advantage of the different types of indexes and partitioning methods, in
order to help speed up the execution of SQL statements.