X-Git-Url: https://dev.renevier.net/?a=blobdiff_plain;f=application%2Fmodels%2FPathMapper.php;h=7f43e2239b64bae6d1187c9ea1c44f6571d77059;hb=38bedcd63499189e0584bfff6e44ae4018283eb1;hp=c89936455905e9c060110665e9d194b864d6adb2;hpb=a64d41557a62ec6051d7fa08d1ba941e089aa5c2;p=syj.git diff --git a/application/models/PathMapper.php b/application/models/PathMapper.php index c899364..7f43e22 100644 --- a/application/models/PathMapper.php +++ b/application/models/PathMapper.php @@ -1,5 +1,5 @@ getDbTable()->getAdapter(); $expr = $db->quoteInto('seq_attained_value(?)', array('paths_id_seq', (int)$id)); $select = $db->select()->from(new Zend_Db_Expr($expr)); - print $select->assemble(); $row = $db->fetchRow($select); return $row['t']; } @@ -42,9 +41,18 @@ class Syj_Model_PathMapper return $this->_fetchItem($select, $path); } - public function fetchAll() { + public function fetchByCreator(Syj_Model_User $user) { $select = $this->_select(); + $select->where('creator = ?', (int)$user->id)->order('id'); + return $this->fetchAll($select); + } + + public function fetchAll(Zend_Db_Table_Select $select) { + if (!isset($select)) { + $select = $this->_select(); + } + $table = $this->getDbTable(); $resultSet = $table->fetchAll($select); $entries = array(); @@ -58,7 +66,7 @@ class Syj_Model_PathMapper public function save (Syj_Model_Path $path) { $data = array( 'geom'=> (string)$path->geom, - 'creator'=> $path->creator->id, + 'creator'=> $path->creator? $path->creator->id: null, 'title'=> $path->title, 'creator_ip'=> $path->creatorIp ); @@ -69,6 +77,10 @@ class Syj_Model_PathMapper } } + public function delete (Syj_Model_Path $path) { + $this->getDbTable()->delete(array('id = ?' => $path->getId())); + } + protected function _itemFromRow(Syj_Model_Path $item, Zend_Db_Table_Row $row) { $decoder = new gisconverter\WKT(); $geom = $decoder->geomFromText($row->wkt);