Login   Register  
PHP Classes
elePHPant
Icontem

File: exampleUsage.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Aziz S. Hussain  >  Database Management Class  >  exampleUsage.php  >  Download  
File: exampleUsage.php
Role: Example script
Content type: text/plain
Description: Example Usage
Class: Database Management Class
Execute MySQL queries using lists of parameters
Author: By
Last change:
Date: 2010-11-16 13:04
Size: 1,592 bytes
 

Contents

Class file image Download
<?php

/*
Written by Aziz S. Hussain
@
www.AzizSaleh.com
Produced under LGPL license
@
http://www.gnu.org/licenses/lgpl.html

*/


// Include
include('database.php');

// Connect
$database = new database('localhost','root','','amana');

// Execute Bind Query
$sql 'INSERT INTO clients (clientName,ClientPhone) VALUES (?,?)';
$database->query($sql,array('TestClient','TestPhone'));

$sql "INSERT INTO clients (clientName,clientPhone) VALUES (?,'311')"
$database->query($sql,'TestName');

// Execute Blind Insert
$_POST = array('clientName' => 'Test''clientPhone' => 411);
$database->insert('clients',$_POST);

// Execute Blind Update
$_POST = array('clientID' => 1'clientName' => 'Test''clientPhone' => 411);
$database->insert('clients',$_POST);

// Get results (by assoc)
$results $database->result('SELECT * FROM clients');
print_r($results);

// Delete records
$database->delete('clients',1);    //-> Delete client at primary key 1 @ clients table
$database->delete('clients','TestName','clientName'); 
                                
//-> Delete user with clientName value of TestName
$database->delete('clients',array('clientName' => 'TestClient''clientPhone' => 311));
                                
//-> Delete user with multiple matches        
// Escape user variables
$safeValue $database->escape($_POST['badValue']);

// Create table
$_POST = array('clientName' => NULL,'clientPhone' => NULL);
$database->createTable('clients',$_POST,'clientID');
                                
//-> Create clients table with clientName,clientPhone and clientID as primary key

// End of file /exampleUsage.php