Login   Register  
PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Nadir Latif  >  Database Functions  >  index.php  >  Download  
File: index.php
Role: Example script
Content type: text/plain
Description: sample file
Class: Database Functions
Build and execute MySQL database queries
Author: By
Last change:
Date: 7 years ago
Size: 2,404 bytes
 

Contents

Class file image Download
<?php
/********************************************************************************************
-The class can be used in two ways. Both are shown below.
-Only update and select queries are shown below.Insert,Delete queries can also be performed
********************************************************************************************/
    
Method1();
    
Method2();
/********************************************************************************************
-Second method for using the class.
********************************************************************************************/
function Method2()
    {
        include_once(
'database_functions.php');    
        
        
$database=new DatabaseFunctions('localhost','root','nadirlatif','new-crm',0,'u');
        
        
$database->df_add_update_field('name','boat','test',true);
        
$database->df_add_update_field('capacity','boat','10',false);
        
$database->df_add_update_field('price','boat','100',false);
        
$database->df_build_where_clause('price','100',false,'boat','<','');
        
$str=$database->df_get_query_string(true);
        
        echo 
'<br/><br/>'.$str.'<br/><br/>';
        
$database->df_execute($str);
        
$database->df_close();        
    }
/********************************************************************************************
-First method for using the class.
********************************************************************************************/
function Method1()
    {
        include_once(
'database_functions.php');
        
        
$database=new DatabaseFunctions();
        
        
$database->df_connect('localhost','root','nadirlatif','new-crm');
        
        
$main_query=array(); 
        
$main_query[0]['field']='name';
        
$main_query[0]['table']='boat';
        
$main_query[1]['field']='capacity';
        
$main_query[1]['table']='boat';
        
$main_query[2]['field']='price';
        
$main_query[2]['table']='boat';
        
        
$where_clause=array();    
        
$where_clause[0]['field']='price';
        
$where_clause[0]['value']='0.00';
        
$where_clause[0]['table']='boat';
        
$where_clause[0]['operation']='=';
        
$where_clause[0]['operator']='AND';
        
        
$where_clause[1]['field']='capacity';
        
$where_clause[1]['value']='500';
        
$where_clause[1]['table']='boat';
        
$where_clause[1]['operation']='=';
        
$where_clause[1]['operator']='';
        
        
$query=$database->df_build_query($main_query,$where_clause,'s');
        
        echo 
$query.'<br/><br/>';
        
        
print_r($database->df_all_rows($query));
    }
?>