PHP Classes

File: example

Recommend this page to a friend!
  Classes of Daniel Vasic   Simple DBase   example   Download  
File: example
Role: Example script
Content type: text/plain
Description: example file
Class: Simple DBase
Simple MySQL database access wrapper
Author: By
Last change:
Date: 14 years ago
Size: 559 bytes
 

Contents

Class file image Download
<?php
define
('HOST', 'localhost');
define('USER', 'root');
define('PASS', '');
define('TABLE', 'cms');

include(
"db_class.inc.php");
$db = new db (HOST, USER, PASS, TABLE);
/*Count rows*/
   
$db->sqlQuery("SELECT null FROM comments");
   
$string = printf("You have ". $db->numRows() . " fields in this table<br />");
   
$db->clearQuery();

/*Fetch data*/
   
$db->sqlQuery("SELECT id, email FROM comments");
    while(
$row = $db->fetchData()){
       
printf("id : %s\temail : %s<br />",$row['id'], $row['email']);
    }
   
$db->clearQuery();
$db->close();

?>