Class P4A_DB_Source

Description

Read/write data from/to a database.

Note that P4A_DB_Source is case sensitive when handling schemas/tables/columns names, thus if your table name is "products" (lowercase) then type it lowercase in P4A too, if it is "PRODUCTS" (uppercase) then type it uppercase in P4A too and so on...

Located in /p4a/objects/data_sources/db_source.php (line 48)

P4A_Object
   |
   --P4A_Data_Source
      |
      --P4A_DB_Source
Variable Summary
 string $_DSN
 array $_fields
 array $_filters
 array $_group
 boolean $_is_sortable
 array $_join
 string $_pk
 string $_query
 string $_schema
 string $_table
 string $_where
Method Summary
 P4A_DB_Source addFilter (string $filter, P4A_Object $obj)
 P4A_DB_Source addGroup (string $group)
 P4A_DB_Source addJoin (string $table, string $clausole, [array $fields = '*'], [string $schema = null])
 P4A_DB_Source addJoinCross (string $table, [array $fields = '*'], [string $schema = null])
 P4A_DB_Source addJoinFull (string $table, string $clausole, [array $fields = '*'], [string $schema = null])
 P4A_DB_Source addJoinInner (string $table, string $clausole, [array $fields = '*'], [string $schema = null])
 P4A_DB_Source addJoinLeft (string $table, string $clausole, [array $fields = '*'], [string $schema = null])
 P4A_DB_Source addJoinNatural (string $table, [array $fields = '*'], [string $schema = null])
 P4A_DB_Source addJoinRight (string $table, string $clausole, [array $fields = '*'], [string $schema = null])
 P4A_DB_Source addMultivalueField (string $fieldname, [string $table = null], [string $fk = null], [string $fk_field = null])
 void createDataField ( $name, [ $meta = null])
 void deleteRow ()
 P4A_DB_Source dropFilter (string $filter)
 array getAll ([integer $from = 0], [integer $count = 0])
 string getDSN ()
 array getFields ()
 void getFilters ()
 array getGroup ()
 array getJoin ()
 void getNumRows ()
 void getPkRow ( $pk)
 string getQuery ()
 void getRowPosition ([ $row = null])
 string getSchema ()
 string getTable ()
 string getWhere ()
 boolean|P4A_DB_Source isReadOnly ([boolean $value = null])
 void load ()
 void row ([ $num_row = null], [ $move_pointer = true])
 void rowByPk ( $pk)
 void saveRow ([array $fields_values = array()], [array $pk_values = array()])
 P4A_DB_Source setDSN (string $DSN)
 P4A_DB_Source setFields ( $fields)
 P4A_DB_Source setGroup (string|array $group)
 P4A_DB_Source setQuery (string $query)
 P4A_DB_Source setSchema (string $schema)
 P4A_DB_Source setTable (string $table)
 P4A_DB_Source setWhere (string $where)
 void _composeGroupPart ( $select)
 void _composeOrderPart ( $select, [ $order = array()])
 void _composePkString ([ $pk_values = array()])
 void _composeSelectCountPart ( $select)
 string _composeSelectCountQuery ([string $query = null])
 void _composeSelectPart ( $select)
 Zend_Db_Select|string _composeSelectPkQuery ( $pk_value)
 Zend_Db_Select|string _composeSelectQuery ([ $add_order_clause = true])
 Zend_Db_Select|string _composeSelectStructureQuery ()
 void _composeWherePart ( $select)
 void __wakeup ()
Variables
string $_DSN = null (line 53)
  • access: protected
array $_fields = array() (line 73)
  • access: protected
array $_filters = array() (line 108)
  • access: protected
array $_group = array() (line 88)
  • access: protected
boolean $_is_sortable = true (line 93)
  • access: protected

Redefinition of:
P4A_Data_Source::$_is_sortable
array $_join = array() (line 78)
  • access: protected
array $_multivalue_fields = array() (line 103)
  • access: protected
string $_pk = null (line 58)
  • access: protected

Redefinition of:
P4A_Data_Source::$_pk
string $_query = null (line 98)
  • access: protected
string $_schema = null (line 68)
  • access: protected
string $_table = null (line 63)
  • access: protected
array $_tables_metadata = array() (line 113)
  • access: protected
string $_where = null (line 83)
  • access: protected

Inherited Variables

Inherited from P4A_Data_Source

P4A_Data_Source::$fields
P4A_Data_Source::$_is_read_only
P4A_Data_Source::$_limit
P4A_Data_Source::$_num_pages
P4A_Data_Source::$_num_rows
P4A_Data_Source::$_offset
P4A_Data_Source::$_order
P4A_Data_Source::$_page_limit
P4A_Data_Source::$_pointer

Inherited from P4A_Object

P4A_Object::$_helpers
P4A_Object::$_id
P4A_Object::$_map_actions
P4A_Object::$_name
P4A_Object::$_objects
P4A_Object::$_parent_id
Methods
addFilter (line 379)
  • access: public
P4A_DB_Source addFilter (string $filter, P4A_Object $obj)
addGroup (line 322)
  • access: public
P4A_DB_Source addGroup (string $group)
  • string $group
addJoin (line 200)

Add a join (default join type is INNER)

  • access: public
P4A_DB_Source addJoin (string $table, string $clausole, [array $fields = '*'], [string $schema = null])
  • string $table
  • string $clausole
  • array $fields
  • string $schema
addJoinCross (line 269)

Add a cross join

  • access: public
P4A_DB_Source addJoinCross (string $table, [array $fields = '*'], [string $schema = null])
  • string $table
  • array $fields
  • string $schema
addJoinFull (line 256)

Add a full join

  • access: public
P4A_DB_Source addJoinFull (string $table, string $clausole, [array $fields = '*'], [string $schema = null])
  • string $table
  • string $clausole
  • array $fields
  • string $schema
addJoinInner (line 214)

Add an inner join

  • access: public
P4A_DB_Source addJoinInner (string $table, string $clausole, [array $fields = '*'], [string $schema = null])
  • string $table
  • string $clausole
  • array $fields
  • string $schema
addJoinLeft (line 228)

Add a left join

  • access: public
P4A_DB_Source addJoinLeft (string $table, string $clausole, [array $fields = '*'], [string $schema = null])
  • string $table
  • string $clausole
  • array $fields
  • string $schema
addJoinNatural (line 282)

Add a natural join

  • access: public
P4A_DB_Source addJoinNatural (string $table, [array $fields = '*'], [string $schema = null])
  • string $table
  • array $fields
  • string $schema
addJoinRight (line 242)

Add a right join

  • access: public
P4A_DB_Source addJoinRight (string $table, string $clausole, [array $fields = '*'], [string $schema = null])
  • string $table
  • string $clausole
  • array $fields
  • string $schema
addMultivalueField (line 1100)
  • access: public
P4A_DB_Source addMultivalueField (string $fieldname, [string $table = null], [string $fk = null], [string $fk_field = null])
  • string $fieldname
  • string $table
  • string $fk
  • string $fk_field
createDataField (line 502)
  • access: protected
void createDataField ( $name, [ $meta = null])
  • $name
  • $meta
deleteRow (line 828)

Removes the row from the database

  • access: public
void deleteRow ()

Redefinition of:
P4A_Data_Source::deleteRow()
dropFilter (line 390)
  • access: public
P4A_DB_Source dropFilter (string $filter)
  • string $filter
getAll (line 861)

Returns all rows as an associative array.

You can get only a subset of all rows using $from and $count parameters.

  • access: public
array getAll ([integer $from = 0], [integer $count = 0])
  • integer $from
  • integer $count

Redefinition of:
P4A_Data_Source::getAll()
getDSN (line 128)
  • access: public
string getDSN ()
getFields (line 187)
  • access: public
array getFields ()
getFilters (line 399)
  • access: public
void getFilters ()
getGroup (line 349)
  • access: public
array getGroup ()
getJoin (line 292)

Get all joins

  • access: public
array getJoin ()
getNumRows (line 634)
  • access: public
void getNumRows ()

Redefinition of:
P4A_Data_Source::getNumRows()
getPkRow (line 565)
  • access: public
void getPkRow ( $pk)
  • $pk

Redefinition of:
P4A_Data_Source::getPkRow()
getQuery (line 369)
  • access: public
string getQuery ()
getRowPosition (line 644)
  • access: public
void getRowPosition ([ $row = null])
  • $row
getSchema (line 169)
  • access: public
string getSchema ()
getTable (line 151)
  • access: public
string getTable ()
getWhere (line 313)

Get the where clausole (in SQL syntax)

  • access: public
string getWhere ()
isReadOnly (line 558)

gets/sets read only state

  • access: public
boolean|P4A_DB_Source isReadOnly ([boolean $value = null])
  • boolean $value
load (line 425)
  • access: public
void load ()

Redefinition of:
P4A_Data_Source::load()
resetNumRows (line 1087)
  • access: public
P4A_DB_Source resetNumRows ()
row (line 572)
  • access: public
void row ([ $num_row = null], [ $move_pointer = true])
  • $num_row
  • $move_pointer

Redefinition of:
P4A_Data_Source::row()
rowByPk (line 627)
  • access: public
void rowByPk ( $pk)
  • $pk
saveRow (line 725)

Inserts/update the row to the database.

If you've multivalue fields be sure that the user can't change the value of primary keys or the record will be broken.

You can pass $fields_values and $pk_values if you want to save a row you created in a custom way bypassing internal data_fields.

  • access: public
void saveRow ([array $fields_values = array()], [array $pk_values = array()])
  • array $fields_values
  • array $pk_values
setDSN (line 119)
  • access: public
P4A_DB_Source setDSN (string $DSN)
  • string $DSN
setFields (line 178)
  • access: public
P4A_DB_Source setFields ( $fields)
  • array $fields
setGroup (line 332)
  • access: public
P4A_DB_Source setGroup (string|array $group)
  • string|array $group
setQuery (line 358)
  • access: public
P4A_DB_Source setQuery (string $query)
  • string $query
setSchema (line 160)
  • access: public
P4A_DB_Source setSchema (string $schema)
  • string $schema
setTable (line 142)

Sets the main table for this data source.

If you pass a database view here, remember that you have to call setPk() on this P4A_DB_Source and setSequence() on the P4A_Data_Fields (if needed) because those data won't be autodetected.

  • access: public
P4A_DB_Source setTable (string $table)
  • string $table
setWhere (line 302)

set the where clausole (in SQL syntax)

  • access: public
P4A_DB_Source setWhere (string $where)
  • string $where
updateRowPosition (line 705)
  • access: public
P4A_DB_Source updateRowPosition ()

Redefinition of:
P4A_Data_Source::updateRowPosition()
_composeGroupPart (line 1044)
  • access: protected
void _composeGroupPart ( $select)
  • $select
_composeOrderPart (line 1051)
  • access: protected
void _composeOrderPart ( $select, [ $order = array()])
  • $select
  • $order
_composePkString (line 1064)
  • access: protected
void _composePkString ([ $pk_values = array()])
  • $pk_values
_composeSelectCountPart (line 1006)
  • access: protected
void _composeSelectCountPart ( $select)
  • $select
_composeSelectCountQuery (line 895)
  • access: protected
string _composeSelectCountQuery ([string $query = null])
  • string $query
_composeSelectPart (line 973)
  • access: protected
void _composeSelectPart ( $select)
  • $select
_composeSelectPkQuery (line 945)
  • access: protected
Zend_Db_Select|string _composeSelectPkQuery ( $pk_value)
  • $pk_value
_composeSelectQuery (line 928)
  • access: protected
Zend_Db_Select|string _composeSelectQuery ([ $add_order_clause = true])
  • $add_order_clause
_composeSelectStructureQuery (line 912)
  • access: protected
Zend_Db_Select|string _composeSelectStructureQuery ()
_composeWherePart (line 1029)
  • access: protected
void _composeWherePart ( $select)
  • $select
__wakeup (line 1136)
  • access: public
void __wakeup ()

Inherited Methods

Inherited From P4A_Data_Source

 P4A_Data_Source::__construct()
 P4A_Data_Source::addOrder()
 P4A_Data_Source::deleteRow()
 P4A_Data_Source::dropOrder()
 P4A_Data_Source::exportAsCSV()
 P4A_Data_Source::exportToCSV()
 P4A_Data_Source::firstPage()
 P4A_Data_Source::firstRow()
 P4A_Data_Source::getAll()
 P4A_Data_Source::getAsCSV()
 P4A_Data_Source::getNumPage()
 P4A_Data_Source::getNumPages()
 P4A_Data_Source::getNumRows()
 P4A_Data_Source::getOffset()
 P4A_Data_Source::getOrder()
 P4A_Data_Source::getPageLimit()
 P4A_Data_Source::getPk()
 P4A_Data_Source::getPkRow()
 P4A_Data_Source::getPkValues()
 P4A_Data_Source::getRowNumber()
 P4A_Data_Source::hasOrder()
 P4A_Data_Source::isNew()
 P4A_Data_Source::isSortable()
 P4A_Data_Source::lastPage()
 P4A_Data_Source::lastRow()
 P4A_Data_Source::load()
 P4A_Data_Source::newRow()
 P4A_Data_Source::nextPage()
 P4A_Data_Source::nextRow()
 P4A_Data_Source::page()
 P4A_Data_Source::prevPage()
 P4A_Data_Source::prevRow()
 P4A_Data_Source::row()
 P4A_Data_Source::saveUploads()
 P4A_Data_Source::setOrder()
 P4A_Data_Source::setPageLimit()
 P4A_Data_Source::setPk()
 P4A_Data_Source::updateRowPosition()

Inherited From P4A_Object

 P4A_Object::__construct()
 P4A_Object::actionHandler()
 P4A_Object::build()
 P4A_Object::destroy()
 P4A_Object::dropImplement()
 P4A_Object::dropMethod()
 P4A_Object::errorHandler()
 P4A_Object::getId()
 P4A_Object::getName()
 P4A_Object::getObjectType()
 P4A_Object::getParentID()
 P4A_Object::implement()
 P4A_Object::intercept()
 P4A_Object::isActionTriggered()
 P4A_Object::setName()
 P4A_Object::setParentID()
 P4A_Object::void()
 P4A_Object::_loadHelper()
 P4A_Object::__call()

Documentation generated on Tue, 02 Sep 2008 10:03:59 +0200 by phpDocumentor 1.4.2