Class DB_storage

Description

Provides an object interface to a table row.

It lets you add, delete and change rows using objects rather than SQL statements.

  • author: Stig Bakken <stig@php.net>
  • version: $Id: storage.php,v 1.17 2004/02/04 01:42:05 danielc Exp $

Located in /maintenance/libraries/pear/DB/storage.php (line 35)

PEAR
   |
   --DB_storage
Variable Summary
 mixed $_changes
 mixed $_dbh
 mixed $_keycolumn
 mixed $_properties
 mixed $_readonly
 mixed $_table
 mixed $_validator
Method Summary
 DB_storage DB_storage ($table $table, $keycolumn $keycolumn, $dbh &$dbh, [$validator $validator = null])
 object a &create ($data $table, mixed &$data)
 void dump ()
 attribute &get (string $property)
 void insert (mixed $newpk)
 mixed remove ()
 void set (mixed $property, mixed $newvalue)
 int setup ($keyval $keyval)
 DB_OK store ()
 string toString ()
 void _DB_storage ()
 void _makeWhere ([mixed $keyval = null])
Variables
mixed $_changes = array() (line 57)

an assoc with the names of the properties in this object that

mixed $_dbh = null (line 49)

DB connection handle used for all transactions

mixed $_keycolumn = null (line 46)

which column(s) in the table contains primary keys, can be a

mixed $_properties = array() (line 53)

an assoc with the names of database fields stored as properties

mixed $_readonly = false (line 62)

flag that decides if data in this object can be changed.

mixed $_table = null (line 41)

the name of the table (or view, if the backend database supports

mixed $_validator = null (line 67)

function or method that implements a validator for fields that

Methods
Constructor DB_storage (line 88)

Constructor

DB_storage DB_storage ($table $table, $keycolumn $keycolumn, $dbh &$dbh, [$validator $validator = null])
  • $table $table: string the name of the database table
  • $keycolumn $keycolumn: mixed string with name of key column, or array of strings if the table has a primary key of more than one column
  • $dbh &$dbh: object database connection object
  • $validator $validator: mixed function or method used to validate each new value, called with three parameters: the name of the field/column that is changing, a reference to the new value and a reference to this object
create (line 284)

Static method used to create new DB storage objects.

  • return: new instance of DB_storage or a subclass of it
object a &create ($data $table, mixed &$data)
  • $data $table: assoc. array where the keys are the names of properties/columns
dump (line 266)

Dump the contents of this object to "standard output".

void dump ()
get (line 402)

Fetch an attribute value.

  • return: contents, or null if the attribute name is unknown
attribute &get (string $property)
  • string $property: attribute name
insert (line 188)

Create a new (empty) row in the configured table for this object.

void insert (mixed $newpk)
remove (line 465)

Remove the row represented by this object from the database.

  • return: DB_OK or a DB error
mixed remove ()
set (line 353)

Modify an attriute value.

void set (mixed $property, mixed $newvalue)
setup (line 158)

Method used to initialize a DB_storage object from the configured table.

  • return: DB_OK on success, a DB error if not
int setup ($keyval $keyval)
  • $keyval $keyval: mixed the key[s] of the row to fetch (string or array)
store (line 437)

Stores changes to this object in the database.

  • return: or a DB error
DB_OK store ()
toString (line 219)

Output a simple description of this DB_storage object.

  • return: object description
string toString ()
_DB_storage (line 419)

Destructor, calls DB_storage::store() if there are changes that are to be kept.

void _DB_storage ()
_makeWhere (line 109)

Utility method to build a "WHERE" clause to locate ourselves in the table.

XXX future improvement: use rowids?

  • access: private
void _makeWhere ([mixed $keyval = null])

Documentation generated on Fri, 11 Feb 2005 18:14:12 +0000 by phpDocumentor 1.3.0RC3