Exemplo n.º 1
0
 /**
  * Saves the row to the database.
  *
  * This performs an update on all children rows when the path changes.
  *
  * @return KDatabaseRowAbstract
  */
 public function save()
 {
     if (!empty($this->id)) {
         $id = $this->id;
         $table = KFactory::get($this->getTable());
         $query = $table->getDatabase()->getQuery();
         $query->where('path', 'like', '%' . $id . '%');
         $path = $this->path;
         $path = $path ? $path . '/' . $id : $id;
         foreach ($table->select($query) as $row) {
             $parts = explode($id, $row->path);
             $part = isset($parts[1]) ? $parts[1] : null;
             $row->path = $path . $part;
             $row->save();
         }
     }
     parent::save();
     return $this;
 }