Login   Register  
PHP Classes
elePHPant
Icontem

File: documentation.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Iván Campaña  >  Data Objects  >  documentation.txt  >  Download  
File: documentation.txt
Role: Documentation
Content type: text/plain
Description: Basic documentation for the class
Class: Data Objects
Supply an interface to treat table rows as objects
Author: By
Last change:
Date: 2005-03-30 09:42
Size: 1,808 bytes
 

Contents

Class file image Download
/**
 * dataObject
 * 
 * Base definition of the data Object
 * 
 * @package 
 * @author Ivan Campaña <ivan.campana@gmail.com>
 * @copyright Copyright (c) 2005 - GNU/GPL License
 * @version 0.1
 * @access public
 **/

This is far from complete, but at least can be used as a start point to know the basics of the object


Creating an new Object
========================

Sample:

$variable = new dataObject( $connection, $tablename);

$connection .- is a valid ADODB connection to any Database, to be able to use the metadata functions of the DB by the time of this release mysql, odbc (including db2, odbc_mssql, etc), mssql, postgres, interbase/firebird, oci8 are currently supported.

$tablename .- is a string indicating the name of the table we want to work with.


Loading data from the DB
========================

Sample:

$dataObject->load($PKs)

$PKs.- it can be a single value or an array of values indicating the id of the register we want to load, based on this the object determines if it is a new register or an existing one.


Saving data in the DB
========================

Sample:

$dataObject->store( )
Sends the changes to the DB, inserting new data or updating the existing data.


Erasing data from the DB
========================

Sample:

$dataObject->delete()

Deletes the currently selected register, based on the data returned by the load function.


Setting and Returning values
========================

Sample:
$dataObject->set( $field_name, $value)
$result = $dataObject->get($field_name)

To set data values, just call the set method indicating the name of the field that you wish to update and the new value.

To get the currently stored value use the get method by just passing the field name as parameter.