get_info($id); foreach ($info as $key=>$value) { $this->$key = $value; } return true; } // Constructor /** * gc * * This cleans out unused personal videos */ public static function gc() { $sql = "DELETE FROM `personal_video` USING `personal_video` LEFT JOIN `video` ON `video`.`id` = `personal_video`.`id` " . "WHERE `video`.`id` IS NULL"; Dba::write($sql); } /** * create * This takes a key'd array of data as input and inserts a new personal video entry, it returns the record id */ public static function insert(array $data, $gtypes = array(), $options = array()) { $sql = "INSERT INTO `personal_video` (`id`,`location`,`summary`) " . "VALUES (?, ?, ?)"; Dba::write($sql, array($data['id'], $data['location'], $data['summary'])); return $data['id']; } // create /** * update * This takes a key'd array of data as input and updates a personal video entry */ public function update(array $data) { parent::update($data); $sql = "UPDATE `personal_video` SET `location` = ?, `summary` = ? WHERE `id` = ?"; Dba::write($sql, array($data['location'], $data['summary'], $this->id)); return $this->id; } // update /** * format * this function takes the object and reformats some values */ public function format($details = true) { parent::format($details); $this->f_location = $this->location; return true; } //format /** * Remove the video from disk. */ public function remove_from_disk() { $deleted = parent::remove_from_disk(); if ($deleted) { $sql = "DELETE FROM `personal_video` WHERE `id` = ?"; $deleted = Dba::write($sql, array($this->id)); } return $deleted; } } // Personal_Video class