Source for file AbstractMapper.php
Documentation is available at AbstractMapper.php
* "THE BEER-WARE LICENSE" (Revision 42):
* "Sven Strittmatter" <ausserirdisch@sven-space.de> wrote this file.
* As long as you retain this notice you can do whatever you want with
* this stuff. If we meet some day, and you think this stuff is worth it,
* you can buy me a beer in return.
* @package MediaSearch_Model
* @copyright Copyright (c) 2009 Sven Strittmatter
* This model class represents a single file with its metadata.
* Its required that each MApper class follows a specific naming schema:
* Model class name for which it mapps plus the suffix 'Mapper'.
* model class -> MediaSearch_Model_Foo
* mapper class -> MediaSearch_Model_FooMapper
* @see Zend_Application_Bootstrap_Bootstrap
* @package MediaSearch_Model
* @copyright Copyright (c) 2009 Sven Strittmatter
* Sets the database table gateway object.
* You can provide a class name as string or an object.
* The objects should be of the class returned by getTableClassName().
* @return MediaSearch_Model_AbstractMapper
$dbTable = new $dbTable();
$requiredType = $this->getTableClassName();
if (!$dbTable instanceof $requiredType) {
throw new Exception('Invalid table data gateway provided');
$this->dbTable = $dbTable;
* Returns the atabase table gateway object.
* Constructs a new one if no one is set.
* @return MediaSearch_Model_DbTable_Abstract
if (null === $this->dbTable) {
* Constructs the required class name depending on the own classname.
* The schema is as followed. The beginning of each class name is
* MediaSearch_Model_DbTable_ after that the trailing part of mapper class
* name is appended to it without the trailing 'Mapper'.
* mapper class -> MediaSearch_Model_FooMapper
* resulting db class -> MediaSearch_Model_DbTable_Foo
private function getTableClassName() {
$tableClassname = substr($thisClassName, strrpos($thisClassName, '_') + 1);
return 'MediaSearch_Model_DbTable_' . str_replace('Mapper', '', $tableClassname);
* Sets up a given model object with the data in the row array.
* @param MediaSearch_Model_FileMeta $fileMeta
abstract protected function createModel($row, MediaSearch_Model_Abstract $model);
* Creates model objectes from multiple rows.
* @param array $resultSet
* Returns the count of data rows in the db table.
public function count() {
public function fetchAll($limit = null, $offset = null) {
$resultSet = $this->getDbTable()->fetchAll(null, null, $limit, $offset);
if (0 == count($resultSet)) {
|