PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Andrés Ortiz  >  MySQLClass  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Some examples using the class
Class: MySQLClass
Modify MySQL database records from parameters
Author: By
Last change:
Date: 7 years ago
Size: 2,195 bytes
 

Contents

Class file image Download
<?
/**
* MySQLClass 0.2 (2007 07 05) Copyright 2007 Andrés Ortiz (@ndreX!)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
**/

    //Demostration
   
include('class.mysql.inc');
   
$mysql = new mysql;


   
/* -- INSERT -- */
    /* insert ( [array] $mixed , [string] $table, [bool] $debug); */
   
$vf = array('fieldName1' => 'ContentToField1', 'fieldName2' => $variable);
   
$mysql->insert($vf,'TableName',true);
   
   
   
/* -- UPDATE -- */
    /* update ( [array] $mixed , [string] $table, [identifier] $id, [bool] $debug); */
   
$vf = array('fieldName1' => 'ChanginData1', 'fieldName2' => $anothervar);
   
$mysql->update($vf,'TableName','id=5',true);
   
   
/* -- DELETE -- */
    /* - Here we have 2 ways - */
    /* - First: only one field - */
    /* delete ( [string] $table , [identifier] $id, NULL ,[bool] $debug); */
   
$mysql->delete('TableName','id=5',null,true);
   
   
/* - Second: more of one field - */
    /* delete ( [string] $table , [identifier] $id, [array] $mixed ,[bool] $debug); */
   
$dels = array(2, 5);
   
$mysql->delete('TableName','id',$dels);
   
   
/* ------------------------------------------------------------------------------------- */
    /* If you have any cuestin about what is happening in the query see the debug...
    /* Comments or Bugs.
    /* MSN: andrex.da@gmail.com
    /* Jabber: andrex.da@gmail.com
    /* GTalk: andrex.da@gmail.com
    /* Yahoo: ax_andrex@yahoo.com
    /* E.mail: andrex.da@gmail.com
    /* ------------------------------------------------------------------------------------- */
?>