Login   Register  
PHP Classes
elePHPant
Icontem

File: Test_Light_Table.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Fabio Xavier de Lima  >  Light Table  >  Test_Light_Table.php  >  Download  
File: Test_Light_Table.php
Role: Example script
Content type: text/plain
Description: Class of example, shows how to use.
Class: Light Table
Execute SQL database queries from parameter lists
Author: By
Last change: correct role
Date: 6 years ago
Size: 1,652 bytes
 

Contents

Class file image Download
<?php
/**
 * @author Fabio Xavier de Lima
 * Creation Date: 02/07/2008
 * Last Modfied: 02/07/2008
 **/

    
require_once 'Db_Light_Table.php';
    require_once 
'Zend/Date.php';
    
    class 
MyTestTable extends Tabela {
    
        protected 
$name 'USU_ONL';
        protected 
$PrimaryKey 'myCod';
        
        protected 
$myCod null;
        protected 
$myName null;
        protected 
$myDate null;
    
    }
    
/*    The lines below are not part of the class.
    They are only to test and demonstrate how to use the object.
*/    
//    Create an instance of the object
    
$UserOnLine = new MyTestTable();
//    Set property
    
$UserOnLine->myName "Fabio";
    
//    Using the select method
    
$records $UserOnLine->select();
    
//    Result of selection
    
print '<br><hr>';
    
print_r($records);
    print 
'<br><hr>';
    
    
$dt = new Zend_Date();
    
$dt->setDate('13/05/1970','dd/MM/yy');
    
//    setting properties of the object
    
$UserOnLine->myCod 10200;
    
$UserOnLine->myName 'Fabio Lima';
    
$UserOnLine->myDate $dt->get('dd/MM/yy');
    
//    Includes a new record in the table, using the values informed above..
    
print "<br>";
    print 
'Registros incluídos:' $UserOnLine->insert();
    
//    Deletes records in the table, using the values informed above.
    
print "<br>";
    print 
'records erased:' $UserOnLine->delete();
    
//    Create a second object, a past record.
//    In this case the object is created with their properties already loaded.
    
$UserOnLine2 = new MyTestTable($records[0]);
    
    print
'<br> field1: '.$UserOnLine2->myCod;
    print
'<br> field2: '.$UserOnLine2->myName;
    print
'<br> field3: '.$UserOnLine2->myDate;

    unset(
$UserOnLine);
    unset(
$UserOnLine2);
?>