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 Ricardo Alexandre Sismeiro  >  mysql_driver  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: examples
Class: mysql_driver
MySQL access wrapper to simplify common queries
Author: By
Last change:
Date: 7 years ago
Size: 2,567 bytes
 

Contents

Class file image Download
<?php

   
require_once('mysql_driver.php');
   
   
$dbase= new mysql_driver();

     
//--------------------------------------------------------------------------------
      //exporting tables to files ...
   
$result=$dbase->export_tables(dirname(__FILE__).'/tables','csv',';',true,0700,true);

     
//--------------------------------------------------------------------------------
    //importing files to tables
   
$result=$dbase->import_tables(dirname(__FILE__).'/tables','csv',';',true,true);

     
//--------------------------------------------------------------------------------
      //get some values from de database ...
   
list(list($result1))=$dbase->consults("select field2 from sometable where field1='1' limit 1","int");
        
    list(
$result2)=$dbase->consults("select field2 from sometable where field1='1' limit 1","str");
            
     
//note $result2['field2'] is equal to $result1

      //--------------------------------------------------------------------------------
      //get the row from the 'sometable' where the primary key is equal to '1'
     
$row=array();
     
$row['primary_key_name']=1;
   
$result=$dbase->get_row($row,'sometable');

     
//--------------------------------------------------------------------------------
      //get all rows from 'sometable' that have the field1 equal to 'somevalue'
     
$row=array();
     
$row['field1']='somevalue';
     
$result=$dbase->get_rows($row,'sometable');

     
//--------------------------------------------------------------------------------
      //get all rows from 'sometable' that have the field1 like 'somevalue' and the field2 like 'othervalue'
   
$row=array();
     
$row['field1']='somevalue';
   
$row['field2']='othervalue';
     
$result=$dbase->get_rows_like($row,'sometable');

     
//--------------------------------------------------------------------------------
    //insert a new row
   
$row=array();
     
$row['field1']='somevalue';
   
$row['field2']='othervalue';
     
$result=$dbase->insert_row($row,'sometable');
   
     
//--------------------------------------------------------------------------------
      //
     
$dbase->query('select now() as field');
       
$result=$dbase->fetch_assoc();
    if (!
$dbase->is_empty){ echo $result['field']; }
     
$dbase->free_result();
     
     
//--------------------------------------------------------------------------------
      //
     
$result=$dbase->datetime();
      echo
"$result";
       
?>