Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of chema garrido  >  phpMyDB  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Usage example
Class: phpMyDB
Run MySQL database queries from parameter lists
Author: By
Last change: v0.2 example
Date: 4 years ago
Size: 1,071 bytes
 

Contents

Class file image Download
<?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_USERDB_PASSDB_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';
?>