Source for file FileMetaMapper.php
Documentation is available at FileMetaMapper.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
* Maps the FileMeta model object to the database table object.
* @package MediaSearch_Model
* @copyright Copyright (c) 2009 Sven Strittmatter
* Saves the given model object persistent.
* @param MediaSearch_Model_FileMeta $fileMeta
public function save(MediaSearch_Model_FileMeta $fileMeta) {
'fileType' => $fileMeta->getFileType(),
'fileName' => $fileMeta->getFileName(),
'filePath' => $fileMeta->getFilePath(),
'fileSize' => $fileMeta->getFileSize(),
'modificationDate' => $fileMeta->getModificationDate(),
'creationDate' => $fileMeta->getCreationDate(),
'keyWords' => $fileMeta->getKeyWords(),
'lastUpdate' => date('Y-m-d H:i:s')
if (null === ($id = $fileMeta->getId())) {
$this->getDbTable()->update($data, array('ID = ?' => $id));
* Finds an file meta in the persistant layer by its id an loads
* it in the given model object.
* @param MediaSearch_Model_FileMeta $fileMeta
public function find($id, MediaSearch_Model_FileMeta $fileMeta) {
if (0 === count($resultSet)) {
$row = $resultSet->current();
$fileMeta->setId($row->ID);
* Sets up a given model object with the data in the row array.
* @todo setOptions benutzen.
* @param MediaSearch_Model_FileMeta $fileMeta
protected function createModel($row, MediaSearch_Model_Abstract $model) {
$model->setFileType($row->fileType)
->setFileName($row->fileName)
->setFilePath($row->filePath)
->setFileSize($row->fileSize)
->setModificationDate($row->modificationDate)
->setCreationDate($row->creationDate)
->setKeyWords($row->keyWords)
->setLastUpdate($row->lastUpdate)
* Creates model objectes from multiple rows.
* @param array $resultSet
foreach ($resultSet as $row) {
$fileMeta->setId($row['ID']);
* Finds data by id. You can optionaly provide type ids.
* @param array $primaryKeys
$select = new Zend_Db_Table_Select($this->getDbTable());
foreach ($primaryKeys as $id) {
$select->orWhere('ID = ?', $id);
foreach ($types as $type) {
$select->orWhere('fileType = ?', $type);
$statement = $select->query();
if (0 === count($resultSet)) {
|