PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Pankaj Kumar Jha   DB connection using MySQL and MySQLi   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Example script
Class: DB connection using MySQL and MySQLi
Access MySQL databases using MySQL or MySQLi
Author: By
Last change:
Date: 11 years ago
Size: 1,203 bytes
 

Contents

Class file image Download
<?php
    error_reporting
(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); // Diaplay php errors
   
   
require_once('classes/interfaceDB.php');// include DB interface
   
    ######## This object is used for operation related to Mysqli
   
$host = 'localhost';
   
$user = 'root';
   
$password = '';
   
$db = 'db';
   
    require_once(
'classes/clsDBMysqli.php');
   
$objDB=new DBMysqli();
    if(!
$objDB->connectDB($host,$user,$password,$db)){ // Connecting to databse
       
echo $objDB->_errorstr ;die; // display connection error
   
}
    global
$objDB; // object to be used to insert and fetch records
   
   
    ######## This object is used for operation related to Mysql
   
   
       
require_once('classes/clsDBMysql.php');
       
$objDB=new DBMysql();
        
        if(!
$objDB->connectDB($host,$user,$password,$db)){ // Connecting to databse
           
echo $objDB->_errorstr ;die; //display connection error
       
}
        global
$objDB; // object to be used to insert and fetch records
    

    
     //Insert into table
    
$falg=$objDB->insert(array('pankaj','pankaj@email.com'),'user');
     if(!
$flag){
        echo
$objDB->_errorstr;
     }
    
    
$result=$objDB->fetchAll("select * from user where id=?",array('name','pankaj'));
    
print_r($result);
    
?>