Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

passed by reference and will be set with the value of the result columns. See
odbc_prepare for an example of use.


integer odbc_fetch_into(integer result, array fields) integer
odbc_fetch_into(integer result, integer row, array fields)


The odbc_fetch_into function gets the specified row for the specified result set and
puts the columns into the fields array. The fields argument must be passed by reference.
The number of columns in the result set is returned. The row argument may be omitted, in
which case the next row in the set is returned.


<?
// connect to database
$Connection = odbc_connect("store", "guest", "guest");


// execute query
$Query = "SELECT name, price ";
$Query .= "FROM catalog ";
$Result = odbc_do($Connection, $Query);


while(odbc_fetch_into($Result, &$fields))
{
$name = $fields[0];
$price = $fields[1];
print("$name: $price
\n");
}


odbc_close($Connection);
?>


boolean odbc_fetch_row(integer result, integer row)


Use odbc_fetch_row to get a row of data from a result set. The data for the row is stored
in internal memory, ready to be retrieved with the odbc_result function. The row
argument is optional and, if left out, the next available row will be returned. FALSE will
be returned when there are no more rows in the result set. See the odbc_result function
for an example of use.


integer odbc_field_len(integer result, integer field)


Use odbc_field_len to get the length of a field in a result set. Fields are numbered
starting with one.


<?
// connect to database
$Connection = odbc_connect("store", "guest", "guest");

Free download pdf