Login   Register  
PHP Classes
elePHPant
Icontem

File: sample.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Sergey Shilko  >  Abstract SQL Table to Object  >  sample.php  >  Download  
File: sample.php
Role: Example script
Content type: text/plain
Description: Sample child of main class
Class: Abstract SQL Table to Object
Map table rows to objects with Active Record
Author: By
Last change:
Date: 2007-04-10 01:29
Size: 1,398 bytes
 

Contents

Class file image Download
<?php

/* Update existing  >>> */

#$foo = new Foo($db);                     #Initialize object with DB object
#$foo->checkout(25);                    #load item details to class
#$hash_array = array('title'=>'sometitle','price'=>'99.99');
#$foo->setNewValues($hash_array);    #update class with new values
#$foo->commit();                        #Commit all changes to db and write log
#3$foo->finish();                        #Finish work with the class.

/* <<< */

/* Create new  >>> */

#$foo = new Foo($db); #Initialize object with DB object
#$hash_array = array('title'=>'sometitle','price'=>'99.99');
#$foo->create($hash_array);               #Commit all changes to db and write log
#$foo->finish();               #Finish work with the class.

/* <<< */

/* Delete record */

#$foo = new Foo($db);            #Initialize object with DB object
#$foo->delete(25);               #Delete item #25
#$foo->finish();               #Finish work with the class.


class Foo extends dbtoclass{
var 
$title;
var 
$price;

var 
$dbtable 'catalog'#table name 
var $pkeyfld 'id';

function 
Foo($db){
        if(
is_object($db)){$this->db $db;}else{die('CLASS MUST HAVE DB');}
}


function 
getTitle(){
return 
$this->title;
}

function 
setTitle($var){
    
$this->title $var;
}
function 
getPrice(){
return 
$this->price;
}

function 
setPrice($var){
    
$this->price $var;
}

}
?>