]> dev.renevier.net Git - syj.git/blobdiff - application/models/PathMapper.php
routes profile
[syj.git] / application / models / PathMapper.php
index 51c2d34ebe19c27288812aecb66f0c38e43d1a10..2bbeabb7a334d1dbff3e75be7f15d34cc81408d6 100644 (file)
@@ -35,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);
@@ -66,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
         );
@@ -74,6 +80,7 @@ class Syj_Model_PathMapper
             $path->id = $this->getDbTable()->insert($data);
         } else {
             $this->getDbTable()->update($data, array('id = ?' => $id));
+            $path->invalidateCache();
         }
     }