Related Class Documentation
Example Code:
<?php
require('../I18N/Arabic.php');
$Arabic = new I18N_Arabic('Query');
echo $Arabic->allForms($_GET['keyword']);
$dbuser = 'root';
$dbpwd = '';
$dbname = 'test';
try {
$dbh = new PDO('mysql:host=localhost;dbname='.$dbname, $dbuser, $dbpwd);
// Set the error reporting attribute
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->exec("SET NAMES 'utf8'");
if ($_GET['keyword'] != '') {
$keyword = @$_GET['keyword'];
$keyword = str_replace('\"', '"', $keyword);
$Arabic->setStrFields('headline');
$Arabic->setMode($_GET['mode']);
$strCondition = $Arabic->getWhereCondition($keyword);
$strOrderBy = $Arabic->getOrderBy($keyword);
} else {
$strCondition = '1';
}
$StrSQL = "SELECT `headline` FROM `aljazeera` WHERE $strCondition ORDER BY $strOrderBy";
$i = 0;
foreach ($dbh->query($StrSQL) as $row) {
$headline = $row['headline'];
$i++;
if ($i % 2 == 0) {
$bg = "#f0f0f0";
} else {
$bg = "#ffffff";
}
echo "<tr bgcolor=\"$bg\"><td><font size=\"2\">$headline</font></td></tr>";
}
// Close the databse connection
$dbh = null;
} catch (PDOException $e) {
echo $e->getMessage();
}
?>
Total execution time is 0.00028800964355469 seconds
Amount of memory allocated to this script is 377512 bytes