query($query, $params = array())

Started by beingchinmay, 08-11-2016, 07:09:13

Previous topic - Next topic

beingchinmayTopic starter

This is the default way of calling queries if you don't need to limit the number of results. If the result contains one or more rows, query() returns a result object; otherwise, it returns a Boolean indicating success.

Here is an example that returns results:

Quote<?php
require_once 'DB.php';
PEAR::setErrorHandling(PEAR_ERROR_DIE, "%s<br />\n");
$dbh = DB::connect("mysql://test@localhost/world");
$result = $dbh->query("SELECT Name FROM City WHERE " .
"CountryCode = 'NOR'");
while ($result->fetchInto($row)) {
print "$row[0]<br />\n";
}