Zend Framework  1.12
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Zend_Db_Table_Row_Abstract Class Reference

Public Member Functions

 __construct (array $config=array())
 Constructor.
 
 __get ($columnName)
 Retrieve row field value.
 
 __set ($columnName, $value)
 Set row field value.
 
 __unset ($columnName)
 Unset row field value.
 
 __isset ($columnName)
 Test existence of row field.
 
 __sleep ()
 Store table, primary key and data in serialized object.
 
 __wakeup ()
 Setup to do on wakeup.
 
 offsetExists ($offset)
 Proxy to __isset Required by the ArrayAccess implementation.
 
 offsetGet ($offset)
 Proxy to __get Required by the ArrayAccess implementation.
 
 offsetSet ($offset, $value)
 Proxy to __set Required by the ArrayAccess implementation.
 
 offsetUnset ($offset)
 Proxy to __unset Required by the ArrayAccess implementation.
 
 init ()
 Initialize object.
 
 getTable ()
 Returns the table object, or null if this is disconnected row.
 
 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.
 
 getTableClass ()
 Query the class name of the Table object for which this Row was created.
 
 isConnected ()
 Test the connected status of the row.
 
 isReadOnly ()
 Test the read-only status of the row.
 
 setReadOnly ($flag)
 Set the read-only status of the row.
 
 select ()
 Returns an instance of the parent table's Zend_Db_Table_Select object.
 
 save ()
 Saves the properties to the database.
 
 delete ()
 Deletes existing rows.
 
 getIterator ()
 
 toArray ()
 Returns the column/value data as an array.
 
 setFromArray (array $data)
 Sets all data in the row from an array.
 
 refresh ()
 Refreshes properties from the database.
 
 getPrimaryKey ($useDirty=true)
 Retrieves an associative array of primary keys.
 
 findDependentRowset ($dependentTable, $ruleKey=null, Zend_Db_Table_Select $select=null)
 Query a dependent table to retrieve rows matching the current row.
 
 findParentRow ($parentTable, $ruleKey=null, Zend_Db_Table_Select $select=null)
 Query a parent table to retrieve the single row matching the current row.
 
 findManyToManyRowset ($matchTable, $intersectionTable, $callerRefRule=null, $matchRefRule=null, Zend_Db_Table_Select $select=null)
 
 __call ($method, array $args)
 Turn magic function calls into non-magic function calls to the above methods.
 

Protected Member Functions

 _transformColumn ($columnName)
 Transform a column name from the user-specified form to the physical form used in the database.
 
 _doInsert ()
 
 _doUpdate ()
 
 _getTable ()
 Retrieves an instance of the parent table.
 
 _getPrimaryKey ($useDirty=true)
 Retrieves an associative array of primary keys.
 
 _getWhereQuery ($useDirty=true)
 Constructs where statement for retrieving row(s).
 
 _refresh ()
 Refreshes properties from the database.
 
 _insert ()
 Allows pre-insert logic to be applied to row.
 
 _postInsert ()
 Allows post-insert logic to be applied to row.
 
 _update ()
 Allows pre-update logic to be applied to row.
 
 _postUpdate ()
 Allows post-update logic to be applied to row.
 
 _delete ()
 Allows pre-delete logic to be applied to row.
 
 _postDelete ()
 Allows post-delete logic to be applied to row.
 
 _prepareReference (Zend_Db_Table_Abstract $dependentTable, Zend_Db_Table_Abstract $parentTable, $ruleKey)
 Prepares a table reference for lookup.
 
 _getTableFromString ($tableName)
 _getTableFromString
 

Protected Attributes

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

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

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. +?

__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.
__isset (   $columnName)

Test existence of row field.

Parameters
string$columnNameThe column key.
Returns
boolean
__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
__sleep ( )

Store table, primary key and data in serialized object.

Returns
array
__unset (   $columnName)

Unset row field value.

Parameters
string$columnNameThe column key.
Returns
Zend_Db_Table_Row_Abstract
Exceptions
Zend_Db_Table_Row_Exception
__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
_delete ( )
protected

Allows pre-delete logic to be applied to row.

Subclasses may override this method.

Returns
void
_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.

_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.

_getPrimaryKey (   $useDirty = true)
protected

Retrieves an associative array of primary keys.

Parameters
bool$useDirty
Returns
array
_getTable ( )
protected

Retrieves an instance of the parent table.

Returns
Zend_Db_Table_Abstract
_getTableFromString (   $tableName)
protected

_getTableFromString

Parameters
string$tableName
Returns
Zend_Db_Table_Abstract
_getWhereQuery (   $useDirty = true)
protected

Constructs where statement for retrieving row(s).

Parameters
bool$useDirty
Returns
array
_insert ( )
protected

Allows pre-insert logic to be applied to row.

Subclasses may override this method.

Returns
void
_postDelete ( )
protected

Allows post-delete logic to be applied to row.

Subclasses may override this method.

Returns
void
_postInsert ( )
protected

Allows post-insert logic to be applied to row.

Subclasses may override this method.

Returns
void
_postUpdate ( )
protected

Allows post-update logic to be applied to row.

Subclasses may override this method.

Returns
void
_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
_refresh ( )
protected

Refreshes properties from the database.

Returns
void
_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.
_update ( )
protected

Allows pre-update logic to be applied to row.

Subclasses may override this method.

Returns
void
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

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.
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.
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.
getIterator ( )
getPrimaryKey (   $useDirty = true)

Retrieves an associative array of primary keys.

Parameters
bool$useDirty
Returns
array
getTable ( )

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

Returns
Zend_Db_Table_Abstract|null
getTableClass ( )

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

Returns
string
init ( )

Initialize object.

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

Returns
void
isConnected ( )

Test the connected status of the row.

Returns
boolean
isReadOnly ( )

Test the read-only status of the row.

Returns
boolean
offsetExists (   $offset)

Proxy to __isset Required by the ArrayAccess implementation.

Parameters
string$offset
Returns
boolean
offsetGet (   $offset)

Proxy to __get Required by the ArrayAccess implementation.

Parameters
string$offset
Returns
string
offsetSet (   $offset,
  $value 
)

Proxy to __set Required by the ArrayAccess implementation.

Parameters
string$offset
mixed$value
offsetUnset (   $offset)

Proxy to __unset Required by the ArrayAccess implementation.

Parameters
string$offset
refresh ( )

Refreshes properties from the database.

Returns
void
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.

select ( )

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

Returns
Zend_Db_Table_Select
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
setReadOnly (   $flag)

Set the read-only status of the row.

Parameters
boolean$flag
Returns
boolean
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
toArray ( )

Returns the column/value data as an array.

Returns
array

Member Data Documentation

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