Public Member Functions | Protected Member Functions | Protected Attributes

Zend_Db_Table_Row_Abstract Class Reference

Inheritance diagram for Zend_Db_Table_Row_Abstract:
Zend_Db_Table_Row

Public Member Functions

 __construct (array $config=array())
 __get ($columnName)
 __set ($columnName, $value)
 __unset ($columnName)
 __isset ($columnName)
 __sleep ()
 __wakeup ()
 offsetExists ($offset)
 offsetGet ($offset)
 offsetSet ($offset, $value)
 offsetUnset ($offset)
 init ()
 getTable ()
 setTable (Zend_Db_Table_Abstract $table=null)
 getTableClass ()
 isConnected ()
 isReadOnly ()
 setReadOnly ($flag)
 select ()
 save ()
 delete ()
 toArray ()
 setFromArray (array $data)
 refresh ()
 findDependentRowset ($dependentTable, $ruleKey=null, Zend_Db_Table_Select $select=null)
 findParentRow ($parentTable, $ruleKey=null, Zend_Db_Table_Select $select=null)
 findManyToManyRowset ($matchTable, $intersectionTable, $callerRefRule=null, $matchRefRule=null, Zend_Db_Table_Select $select=null)
 __call ($method, array $args)

Protected Member Functions

 _transformColumn ($columnName)
 _doInsert ()
 _doUpdate ()
 _getTable ()
 _getPrimaryKey ($useDirty=true)
 _getWhereQuery ($useDirty=true)
 _refresh ()
 _insert ()
 _postInsert ()
 _update ()
 _postUpdate ()
 _delete ()
 _postDelete ()
 _prepareReference (Zend_Db_Table_Abstract $dependentTable, Zend_Db_Table_Abstract $parentTable, $ruleKey)
 _getTableFromString ($tableName)

Protected Attributes

 $_data = array()
 $_cleanData = array()
 $_modifiedFields = array()
 $_table = null
 $_connected = true
 $_readOnly = false
 $_tableClass = null
 $_primary

Detailed Description

Definition at line 35 of file Abstract.php.


Constructor & Destructor Documentation

__construct ( array $  config = array() )

Constructor.

Supported params for $config are:-

Parameters:
array$configOPTIONAL Array of user-specified config options.
Returns:
void
Exceptions:
Zend_Db_Table_Row_Exception

Definition at line 114 of file Abstract.php.


Member Function Documentation

__call ( method,
array $  args 
)

Turn magic function calls into non-magic function calls to the above methods.

Parameters:
string$method
array$argsOPTIONAL Zend_Db_Table_Select query modifier
Returns:
Zend_Db_Table_Row_Abstract|Zend_Db_Table_Rowset_Abstract
Exceptions:
Zend_Db_Table_Row_ExceptionIf an invalid method is called.

Recognize methods for Has-Many cases: findParent<Class>() findParent<Class>By<Rule>() Use the non-greedy pattern repeat modifier e.g. +?

Recognize methods for Many-to-Many cases: find<Class1>Via<Class2>() find<Class1>Via<Class2>By<Rule>() find<Class1>Via<Class2>By<Rule1>And<Rule2>() Use the non-greedy pattern repeat modifier e.g. +?

Recognize methods for Belongs-To cases: find<Class>() find<Class>By<Rule>() Use the non-greedy pattern repeat modifier e.g. +?

Definition at line 1102 of file Abstract.php.

__get ( columnName )

Retrieve row field value

Parameters:
string$columnNameThe user-specified column name.
Returns:
string The corresponding column value.
Exceptions:
Zend_Db_Table_Row_Exceptionif the $columnName is not a column in the row.

Definition at line 174 of file Abstract.php.

__isset ( columnName )

Test existence of row field

Parameters:
string$columnNameThe column key.
Returns:
boolean

Definition at line 231 of file Abstract.php.

__set ( columnName,
value 
)

Set row field value

Parameters:
string$columnNameThe column key.
mixed$valueThe value for the property.
Returns:
void
Exceptions:
Zend_Db_Table_Row_Exception

Definition at line 192 of file Abstract.php.

__sleep (  )

Store table, primary key and data in serialized object

Returns:
array

Definition at line 242 of file Abstract.php.

__unset ( columnName )

Unset row field value

Parameters:
string$columnNameThe column key.
Returns:
Zend_Db_Table_Row_Abstract
Exceptions:
Zend_Db_Table_Row_Exception

Definition at line 210 of file Abstract.php.

__wakeup (  )

Setup to do on wakeup. A de-serialized Row should not be assumed to have access to a live database connection, so set _connected = false.

Returns:
void

Definition at line 254 of file Abstract.php.

_delete (  ) [protected]

Allows pre-delete logic to be applied to row. Subclasses may override this method.

Returns:
void

Definition at line 812 of file Abstract.php.

_doInsert (  ) [protected]
Returns:
mixed The primary key value(s), as an associative array if the key is compound, or a scalar if the key is single-column.

A read-only row cannot be saved.

Run pre-INSERT logic

Execute the INSERT (this may throw an exception)

Normalize the result to an array indexed by primary key column(s). The table insert() method may return a scalar.

Save the new primary key value in _data. The primary key may have been generated by a sequence or auto-increment mechanism, and this merge should be done before the _postInsert() method is run, so the new values are available for logging, etc.

Run post-INSERT logic

Update the _cleanData to reflect that the data has been inserted.

Definition at line 447 of file Abstract.php.

_doUpdate (  ) [protected]
Returns:
mixed The primary key value(s), as an associative array if the key is compound, or a scalar if the key is single-column.

A read-only row cannot be saved.

Get expressions for a WHERE clause based on the primary key value(s).

Run pre-UPDATE logic

Compare the data to the modified fields array to discover which columns have been changed.

Were any of the changed columns part of the primary key?

Execute cascading updates against dependent tables. Do this only if primary key value(s) were changed.

Execute the UPDATE (this may throw an exception) Do this only if data values were changed. Use the $diffData variable, so the UPDATE statement includes SET terms only for data values that changed.

Run post-UPDATE logic. Do this before the _refresh() so the _postUpdate() function can tell the difference between changed data and clean (pre-changed) data.

Refresh the data just in case triggers in the RDBMS changed any columns. Also this resets the _cleanData.

Return the primary key value(s) as an array if the key is compound or a scalar if the key is a scalar.

Definition at line 505 of file Abstract.php.

_getPrimaryKey ( useDirty = true ) [protected]

Retrieves an associative array of primary keys.

Parameters:
bool$useDirty
Returns:
array

Definition at line 701 of file Abstract.php.

_getTable (  ) [protected]

Retrieves an instance of the parent table.

Returns:
Zend_Db_Table_Abstract

Definition at line 686 of file Abstract.php.

_getTableFromString ( tableName ) [protected]

_getTableFromString

Parameters:
string$tableName
Returns:
Zend_Db_Table_Abstract

Definition at line 1162 of file Abstract.php.

_getWhereQuery ( useDirty = true ) [protected]

Constructs where statement for retrieving row(s).

Parameters:
bool$useDirty
Returns:
array

Definition at line 727 of file Abstract.php.

_insert (  ) [protected]

Allows pre-insert logic to be applied to row. Subclasses may override this method.

Returns:
void

Definition at line 772 of file Abstract.php.

_postDelete (  ) [protected]

Allows post-delete logic to be applied to row. Subclasses may override this method.

Returns:
void

Definition at line 822 of file Abstract.php.

_postInsert (  ) [protected]

Allows post-insert logic to be applied to row. Subclasses may override this method.

Returns:
void

Definition at line 782 of file Abstract.php.

_postUpdate (  ) [protected]

Allows post-update logic to be applied to row. Subclasses may override this method.

Returns:
void

Definition at line 802 of file Abstract.php.

_prepareReference ( Zend_Db_Table_Abstract dependentTable,
Zend_Db_Table_Abstract parentTable,
ruleKey 
) [protected]

Prepares a table reference for lookup.

Ensures all reference keys are set and properly formatted.

Parameters:
Zend_Db_Table_Abstract$dependentTable
Zend_Db_Table_Abstract$parentTable
string$ruleKey
Returns:
array

Definition at line 836 of file Abstract.php.

_refresh (  ) [protected]

Refreshes properties from the database.

Returns:
void

Definition at line 751 of file Abstract.php.

_transformColumn ( columnName ) [protected]

Transform a column name from the user-specified form to the physical form used in the database. You can override this method in a custom Row class to implement column name mappings, for example inflection.

Parameters:
string$columnNameColumn name given.
Returns:
string The column name after transformation applied (none by default).
Exceptions:
Zend_Db_Table_Row_Exceptionif the $columnName is not a string.

Definition at line 157 of file Abstract.php.

_update (  ) [protected]

Allows pre-update logic to be applied to row. Subclasses may override this method.

Returns:
void

Definition at line 792 of file Abstract.php.

delete (  )

Deletes existing rows.

Returns:
int The number of rows deleted.

A read-only row cannot be deleted.

Execute pre-DELETE logic

Execute cascading deletes against dependent tables

Execute the DELETE (this may throw an exception)

Execute post-DELETE logic

Reset all fields to null to indicate that the row is not there

Definition at line 594 of file Abstract.php.

findDependentRowset ( dependentTable,
ruleKey = null,
Zend_Db_Table_Select select = null 
)

Query a dependent table to retrieve rows matching the current row.

Parameters:
string | Zend_Db_Table_Abstract$dependentTable
stringOPTIONAL $ruleKey
Zend_Db_Table_SelectOPTIONAL $select
Returns:
Zend_Db_Table_Rowset_Abstract Query result from $dependentTable
Exceptions:
Zend_Db_Table_Row_ExceptionIf $dependentTable is not a table or is not loadable.

Definition at line 861 of file Abstract.php.

findManyToManyRowset ( matchTable,
intersectionTable,
callerRefRule = null,
matchRefRule = null,
Zend_Db_Table_Select select = null 
)
Parameters:
string | Zend_Db_Table_Abstract$matchTable
string | Zend_Db_Table_Abstract$intersectionTable
stringOPTIONAL $callerRefRule
stringOPTIONAL $matchRefRule
Zend_Db_Table_SelectOPTIONAL $select
Returns:
Zend_Db_Table_Rowset_Abstract Query result from $matchTable
Exceptions:
Zend_Db_Table_Row_ExceptionIf $matchTable or $intersectionTable is not a table class or is not loadable.

Definition at line 984 of file Abstract.php.

findParentRow ( parentTable,
ruleKey = null,
Zend_Db_Table_Select select = null 
)

Query a parent table to retrieve the single row matching the current row.

Parameters:
string | Zend_Db_Table_Abstract$parentTable
stringOPTIONAL $ruleKey
Zend_Db_Table_SelectOPTIONAL $select
Returns:
Zend_Db_Table_Row_Abstract Query result from $parentTable
Exceptions:
Zend_Db_Table_Row_ExceptionIf $parentTable is not a table or is not loadable.

Definition at line 917 of file Abstract.php.

getTable (  )

Returns the table object, or null if this is disconnected row

Returns:
Zend_Db_Table_Abstract|null

Definition at line 321 of file Abstract.php.

getTableClass (  )

Query the class name of the Table object for which this Row was created.

Returns:
string

Definition at line 374 of file Abstract.php.

init (  )

Initialize object

Called from __construct() as final step of object instantiation.

Returns:
void

Definition at line 312 of file Abstract.php.

isConnected (  )

Test the connected status of the row.

Returns:
boolean

Definition at line 384 of file Abstract.php.

isReadOnly (  )

Test the read-only status of the row.

Returns:
boolean

Definition at line 394 of file Abstract.php.

offsetExists ( offset )

Proxy to __isset Required by the ArrayAccess implementation

Parameters:
string$offset
Returns:
boolean

Definition at line 266 of file Abstract.php.

offsetGet ( offset )

Proxy to __get Required by the ArrayAccess implementation

Parameters:
string$offset
Returns:
string

Definition at line 278 of file Abstract.php.

offsetSet ( offset,
value 
)

Proxy to __set Required by the ArrayAccess implementation

Parameters:
string$offset
mixed$value

Definition at line 290 of file Abstract.php.

offsetUnset ( offset )

Does nothing Required by the ArrayAccess implementation

Parameters:
string$offset

Definition at line 301 of file Abstract.php.

refresh (  )

Refreshes properties from the database.

Returns:
void

Definition at line 676 of file Abstract.php.

save (  )

Saves the properties to the database.

This performs an intelligent insert/update, and reloads the properties with fresh data from the table on success.

Returns:
mixed The primary key value(s), as an associative array if the key is compound, or a scalar if the key is single-column.

If the _cleanData array is empty, this is an INSERT of a new row. Otherwise it is an UPDATE.

Definition at line 429 of file Abstract.php.

select (  )

Returns an instance of the parent table's Zend_Db_Table_Select object.

Returns:
Zend_Db_Table_Select

Definition at line 415 of file Abstract.php.

setFromArray ( array $  data )

Sets all data in the row from an array.

Parameters:
array$data
Returns:
Zend_Db_Table_Row_Abstract Provides a fluent interface

Definition at line 660 of file Abstract.php.

setReadOnly ( flag )

Set the read-only status of the row.

Parameters:
boolean$flag
Returns:
boolean

Definition at line 405 of file Abstract.php.

setTable ( Zend_Db_Table_Abstract table = null )

Set the table object, to re-establish a live connection to the database for a Row that has been de-serialized.

Parameters:
Zend_Db_Table_Abstract$table
Returns:
boolean
Exceptions:
Zend_Db_Table_Row_Exception

Definition at line 334 of file Abstract.php.

toArray (  )

Returns the column/value data as an array.

Returns:
array

Definition at line 649 of file Abstract.php.


The documentation for this class was generated from the following file: