Seo Forum & AI

Coding & Programming => Programming Forum => PHP Forum => Topic started by: beingchinmay on 08-11-2016, 08:09:13

Title: query($query, $params = array())
Post by: beingchinmay on 08-11-2016, 08:09:13
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";
}