public static function getLanguageById($id)
 {
     if (is_null(Language::$lang) || Language::$lang->id != $id) {
         $lang = Identifiable::getItemById("'{$id}'", new Language());
         Language::$lang = $lang;
     }
     return Language::$lang;
 }
 public function on_update()
 {
     parent::on_update();
     $db = DB::getInstance();
     $oRef = new ReflectionClass($this->getSpiderClassName());
     $oSpider = $oRef->newInstance(array());
     $table = $oSpider->table['table'];
     $rs = Identifiable::getItemById($this->spiderID, $table);
     $oSpider = $oRef->newInstance($rs);
     $oSpider->description = strip_tags($this->description);
     $oSpider->name = $this->name;
     $oSpider->save();
 }
 /**
  * Update object to DB
  * Walk through the object's attrs
  * and escape them
  *
  * @return bool
  */
 protected function update()
 {
     $pk = $this->getPkValues();
     $data = $this->getAttrs();
     foreach ($this->table['PK'] as $key => $val) {
         unset($data[$key]);
     }
     try {
         array_walk($data, array($this, 'escape'));
     } catch (InvalidValue $e) {
         throw new AppException($e->getMessage());
     }
     $k = array_keys($data);
     $v = array_values($data);
     $c = join(",", array_map(array($this, 'joinAll'), $k, $v));
     $q = "UPDATE {$this->table['table']} SET {$c} WHERE {$pk}";
     $db = DB::getInstance();
     $old = Identifiable::getItemById($this->id, $this);
     if (!$db->db_query($q)) {
         if ($db->db_errno() == 1062) {
             throw new DuplicateEntry($db->db_error());
         } else {
             throw new AppException("Error updating object. Query [{$q}] {$db->db_error()}", true);
         }
     }
     $this->on_update($old);
 }
 public static function getUserById($id)
 {
     return parent::getItemById($id, new User());
 }
 public static function getGroupById($id)
 {
     return parent::getItemById($id, new Group());
 }