DB_DataObject
[ class tree: DB_DataObject ] [ index: DB_DataObject ] [ all elements ]

Class: DB_DataObject_Generator

Source Location: /DB_DataObject-0.12/DataObject/Generator.php

Class Overview

DB_DataObject
   |
   --DB_DataObject_Generator

The main "DB_DataObject" class is really a base class for your own tables classes


Author(s):

Methods


Inherited Variables

Inherited Methods

Class: DB_DataObject

DB_DataObject::count()
find the number of results from a simple query
DB_DataObject::debug()
Debugger. - use this in your extended classes to output debugging information.
DB_DataObject::debugLevel()
sets and returns debug level eg. DB_DataObject::debugLevel(4);
DB_DataObject::delete()
Deletes items from table which match current objects variables
DB_DataObject::fetch()
fetches next row into this objects var's
DB_DataObject::fetchRow()
fetches a specific row into this object variables
DB_DataObject::find()
find results, either normal or crosstable
DB_DataObject::get()
Get a result using key, value.
DB_DataObject::getDatabaseConnection()
Gets the DB object related to an object - so you can use funky peardb stuf with it :)
DB_DataObject::getDatabaseResult()
Gets the DB result object related to the objects active query
  • so you can use funky pear stuff with it - like pager for example.. :)
DB_DataObject::getLink()
return name from related object
DB_DataObject::getLinkArray()
return a list of options for a linked table
DB_DataObject::getLinks()
load related objects
DB_DataObject::groupBy()
Adds a group by condition
DB_DataObject::insert()
Insert the current objects variables into the database
DB_DataObject::joinAdd()
joinAdd - adds another dataobject to this, building a joined query.
DB_DataObject::limit()
Sets the Limit
DB_DataObject::orderBy()
Adds a order by condition
DB_DataObject::query()
sends raw query to database
DB_DataObject::raiseError()
Default error handling is to create a pear error, but never return it.
DB_DataObject::selectAdd()
Adds a select columns
DB_DataObject::setFrom()
Copies items that are in the table definitions from an array or object into the current object will not override key values.
DB_DataObject::staticGet()
An autoloading, caching static get method using key, value (based on get)
DB_DataObject::staticInitialize()
Define the $GLOBALS['_DB_DATAOBJECT_PRODUCTION'] variable
DB_DataObject::update()
Updates current objects variables into the database uses the _get_keys() to decide how to update Returns the true on success
DB_DataObject::validate()
validate - override this to set up your validation rules
DB_DataObject::whereAdd()
Adds a condition to the WHERE statement, defaults to AND

Class Details

[line 54]
The main "DB_DataObject" class is really a base class for your own tables classes

// Set up the class by creating an ini file (refer to the manual for more details [DB_DataObject] database = mysql:/username:password@host/database schema_location = /home/myapplication/database class_location = /home/myapplication/DBTables/ clase_prefix = DBTables_

//Start and initialize...................... - dont forget the & $config = parse_ini_file('example.ini',true); $options = &PEAR::setStaticProperty('DB_DataObject','options'); $options = $config['DB_DataObject'];

// example of a class (that does not use the 'auto generated tables data') class mytable extends DB_DataObject { // mandatory - set the table var $_database_dsn = "mysql://username:password@localhost/database"; var $__table = "mytable"; function _get_table() { return array( 'id' => 1, // integer or number 'name' => 2, // string ); } function _get_keys() { return array('id'); } }

// use in the application

Simple get one row

$instance = new mytable; $instance->get("id",12); echo $instance->somedata;

Get multiple rows

$instance = new mytable; $instance->whereAdd("ID > 12"); $instance->whereAdd("ID < 14"); $instance->find(); while ($instance->fetch()) { echo $instance->somedata; }



[ Top ]


Method Detail

derivedHookFunctions   [line 448]

string derivedHookFunctions( )

hook to add extra methods to all classes

called once for each class, use with $this->table and $this->_definitions[$this->table], to get data out of the current table, use it to add extra methods to the default classes.

  • Return: added to class eg. functions.
  • Access: public

[ Top ]

derivedHookVar   [line 465]

string derivedHookVar( object t &$t, int $padding)

hook for var lines called each time a var line is generated, override to add extra var lines
  • Return: added to class eg. functions.
  • Access: public

Parameters:

object t   &$t     containing type,len,flags etc. from tableInfo call
int   $padding     padding number of spaces

[ Top ]

generateClasses   [line 286]

void generateClasses( )


[ Top ]

start   [line 91]

none start( )

The 'starter' = call this to start the process
  • Access: public

[ Top ]


Documentation generated on Fri, 30 Apr 2004 22:11:21 +0200 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.