PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of marcelo entraigas   AMD   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example - main file
Class: AMD
Add, modify and delete MySQL table records
Author: By
Last change: file update
Date: 14 years ago
Size: 1,002 bytes
 

Contents

Class file image Download
<?php
 
/**
  * This is a basic example of using the Add-Modify-Delete class
  */

    # default database configuration
   
$cfg_resource['default'] = array(
       
'server' => 'localhost',
       
'database' => 'tradeaxes',
       
'user' => 'tradeaxes',
       
'pass' => 'tradeaxes',
    );

   
#main includes
   
require_once('class.Error.php');
    require_once(
'class.Database.php');
    require_once(
'class.Amd.php');

   
#create an Amd (Add-Modify-Delete) object
   
$amd = new Amd();
   
   
//add, Modify or Delete database records...
   
if($_POST){
       
//insert or update
       
$amd->set($_POST, 'users');
    }elseif (isset(
$_GET['del'])){
       
//delete
       
$amd->delete($_GET, 'users');
    }
   
   
//by default list users
   
$include = 'tpl.list_user.php';
    if(isset(
$_GET['id']))
       
$include = 'tpl.set_user.php';
?>
<html>
<head>
<title>AMD example</title>
</head>
<body>
<?php
   
include($include);
    echo
'<br>',$amd->getErrors();
    if(
$amd->sql != '')
        echo
'<br><b>AMD=</b> ',$amd->sql;
?>
</body>
</html>