User's Manual

Navigating Through Database Records
4-6 Oracle Database Express Edition 2 Day Plus PHP Developer Guide Beta Draft
if (!$stid) {
db_error($conn, __FILE__, __LINE__);
}
// Bind the PHP values to query bind parameters
foreach ($bindvars as $b) {
// create local variable with caller specified bind value
$$b[0] = $b[1];
// oci_bind_by_name(resource, bv_name, php_variable, length)
$r = oci_bind_by_name($stid, ":$b[0]", $$b[0], $b[2]);
if (!$r) {
db_error($stid, __FILE__, __LINE__);
}
}
$r = oci_execute($stid, OCI_DEFAULT);
...
}
...
?>
The binding is performed in the foreach loop before the oci_execute() is
done.
For each entry in $bindvars array, the first element contains the query bind
variable name that is used to create a PHP variable of the same name, that is,
$$b[0] takes the value 'DID' in $b[0] and forms a PHP variable called $DID
whose value is assigned from the second element in the entry.
The oci_bind_by_name() accepts four parameters: the $stid as the resource, a
string representing the bind variable name in the query derived from the first
element in the array entry, the PHP variable containing the value to be associated
with the bind variable, and the length of the input value.
3. To test the results of the preceding modifications, save the anyco.php and
anyco_db.inc files and enter the following URL:
http://localhost/~<username>/chap4/anyco.php
The page returned in the browser window should resemble the following page:
Navigating Through Database Records
Adding navigation through the database requires several important changes to the
application logic. The modifications require the combination of:
Q Including a HTML form to provide Next and Previous navigation buttons to step
through data records.