Hallo,
Naja, active-record wäre das dann, oder? Kann sein, muss nicht. Dann regelt die Klasse den Zugriff auf die Datensätze, oder? ZF kennt auch eine DB_Row-Klasse glaub ich. Aber fetchAssoc() gibt bestimmt die Zeilenwerte als assoziatives _Array_ wieder.
http://framework.zend.com/manual/de/zend.db.table.row.html
bzw.
http://framework.zend.com/apidoc/core/ und darin eben die Klasse:
http://framework.zend.com/apidoc/core/Zend_Db/Table/Zend_Db_Table_Row.html
Der Zugriff auf Daten ist über die Methoden geregelt. __get/set wird auch - wie ich finde garnicht so unübersichtlich - genutzt.
abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
{
/**
* The data for each column in the row (column_name => value).
* The keys must match the physical names of columns in the
* table for which this row is defined.
*
* @var array
*/
protected $_data = array();
/**
* This is set to a copy of $_data when the data is fetched from
* a database, specified as a new tuple in the constructor, or
* when dirty data is posted to the database with save().
*
* @var array
*/
protected $_cleanData = array();
/**
* Tracks columns where data has been updated. Allows more specific insert and
* update operations.
*
* @var array
*/
protected $_modifiedFields = array();
/**
* Zend_Db_Table_Abstract parent class or instance.
*
* @var Zend_Db_Table_Abstract
*/
protected $_table = null;
/**
* Connected is true if we have a reference to a live
* Zend_Db_Table_Abstract object.
* This is false after the Rowset has been deserialized.
*
* @var boolean
*/
protected $_connected = true;
/**
* A row is marked read only if it contains columns that are not physically represented within
* the database schema (e.g. evaluated columns/Zend_Db_Expr columns). This can also be passed
* as a run-time config options as a means of protecting row data.
*
* @var boolean
*/
protected $_readOnly = false;
/**
* Name of the class of the Zend_Db_Table_Abstract object.
*
* @var string
*/
protected $_tableClass = null;
/**
* Primary row key(s).
*
* @var array
*/
protected $_primary;
...
//////
//////
////// alles nur protected bis hierher ...
//////
//////
...
///// zentrale Methode __get regelt den Zugriff auf protected vars:
/**
* Retrieve row field value
*
* @param string $columnName The user-specified column name.
* @return string The corresponding column value.
* @throws Zend_Db_Table_Row_Exception if the $columnName is not a column in the row.
*/
public function __get($columnName)
{
$columnName = $this->_transformColumn($columnName);
if (!array_key_exists($columnName, $this->_data)) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception("Specified column \"$columnName\" is not in the row");
}
return $this->_data[$columnName];
}
...
Gruß
jobo