PHP Classes
elePHPant
Icontem

File: example.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of solomongaby  >  MySQL-class  >  example.txt  >  Download  
File: example.txt
Role: Example script
Content type: text/plain
Description: examples of use
Class: MySQL-class
MySQL database access wrapper
Author: By
Last change: added new examples
Date: 7 years ago
Size: 1,154 bytes
 

Contents

Class file image Download
<?php

// conection
$mysql= new mysql('localhost' , 'userSQL', 'passwSQL', 'Selected_DB' );
$mysql->connect();

// fetch row
$row=$mysql->fetch_row( 'TableName', " id='12' ");

// fetch array of rows
$rows=$mysql->list_table( 'TableName', " column='3' ", array ('range' => 'id,name') );

// fetch rows from multiple tables
$rows=$mysql->list_table( ' TableName1 t1,TableName1 t2 ', " t1.column1=t2.column2 ", array ('range' => ' t1.column1_1, t2.column1_2 ') );


// fetch whole table
$tableList=$mysql->list_table( 'TableName', false , );


// fetch a part of a table - pagination example
$parameters['limitOffset']=10; # Offet Start
$parameters['rowCount']=10; # No of rows returned
$where=" columnName='3' ";
$tableList=$mysql->list_table( 'TableName', where , $parameters );

$data=array('columnName1' => 'value1',
           
'columnName2' => 'value2',
           
'columnName3' => 'value3',
            );
// insert data ... it returns true or false
$insertAtempt=$mysql->record_insert('TableName',$data);

// update data
$updateAtempt=$mysql->record_update('TableName',$data," id='3' ");

   
?>