PHP Classes

File: autoexecute.php

Recommend this page to a friend!
  Classes of Ahmed   MySQL DB Management Class   autoexecute.php   Download  
File: autoexecute.php
Role: Example script
Content type: text/plain
Description: example to use autoexecute method
Class: MySQL DB Management Class
Execute MySQL queries and show paginated results
Author: By
Last change:
Date: 15 years ago
Size: 926 bytes
 

Contents

Class file image Download
<?php

/**
 * @package Mysql DB Management Examples
 * @author Ahmed Elbshry(bondo2@bondo2.info)
 * @copyright 2008
 * @access public
 */

try{
    require
'./db.class.php';
   
//الاتصال بقاعدة البيانات مع واخذ نسخه من الكلاس فى خطوة واحده
   
$db = new DB('localhost','root','');
   
   
//اختيار قاعدة البيانات التى سنتعامل معها
   
$db->UseDB('test');
   
   
//طريقة اضافة سجل جديد عن طريق AutoExecute
   
$keys_values = array(
           
'testid' => null,
           
'testname' => 'Ahmed',
           
'testdescription' => 'Here we are',
           
'viewed' => 1010
           
);
   
$res = $db->AutoExecute('test',$keys_values,AUTO_INSERT);
    echo
$res.' is the result of insert<br>';
   
   
//طريقة التعديل على سجل
   
$keys_values = array(
           
'viewed' => 2020
           
);
   
$res = $db->AutoExecute('test',$keys_values,AUTO_UPDATE,'viewed=1010');
    echo
$res.' is the result of update<br>';
   
$db->Close();
}
catch(
exception $e) {
    echo
$e->getMessage();
}
?>