X-Git-Url: https://dev.renevier.net/?p=syj.git;a=blobdiff_plain;f=application%2Fmodels%2FPathMapper.php;h=2bbeabb7a334d1dbff3e75be7f15d34cc81408d6;hp=1e0e973c4489dc0e1bb9673cefcbeb30c949a72d;hb=00c2579ade64a20ba2d82e98d3eea5f864864cdb;hpb=ec061a75fe57a25eb7ef0894f5e723397ba35472 diff --git a/application/models/PathMapper.php b/application/models/PathMapper.php index 1e0e973..2bbeabb 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']; } @@ -36,6 +35,12 @@ class Syj_Model_PathMapper return $this->_fetchItem($select, $path); } + public function findByTitle($title, Syj_Model_Path $path) { + $select = $this->_select(); + $select->where('title = ?', (string)$title); + return $this->_fetchItem($select, $path); + } + public function findByUrl($url, Syj_Model_Path $path) { $select = $this->_select(); $select->where('id = ?', (int)$url)->orWhere('urlcomp = ?', (string)$url); @@ -67,7 +72,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 ); @@ -75,6 +80,7 @@ class Syj_Model_PathMapper $path->id = $this->getDbTable()->insert($data); } else { $this->getDbTable()->update($data, array('id = ?' => $id)); + $path->invalidateCache(); } }