<?php
include "phpMyDB.php";
define('DB_HOST','localhost');
define('DB_USER','user');
define('DB_PASS','some pass');
define('DB_NAME','openclassifieds');
define('DB_CHARSET','utf8');
$ocdb = new phpMyDB(DB_USER, DB_PASS, DB_NAME,DB_HOST,DB_CHARSET);
$ocdb->setDebug(true);
$ocdb->setCache(true,10);
$ocdb->insert("postshits (idPost,ip)","97,'10.0.0.0'");
echo 'test insert see id:' . $ocdb->getLastID();
$query="SELECT count(*) total FROM oc_posts";
$total_records = $ocdb->getValue($query,"APP");
echo 'Total records: '.$total_records;
$query="SELECT p.title from oc_posts p Limit 3";
$ocdb->setCache(false);//cache deactivated
$result=$ocdb->getRows($query,"object");
$ocdb->setCache(true);//after the query is done activated once more
if ($result){//more than 1 result
foreach ( $result as $row ){
echo $row['title'];
}
}//if count
else echo "nothing found";
$ocdb->closeDB();
$ocdb->returnDebug();
echo $ocdb->getQueryCounter().' queries generated and '.$ocdb->getQueryCounter("cache").' queries cached';
?>
|