get_info($id); foreach ($info as $key=>$value) { $this->$key = $value; } return true; } // Constructor /** * gc * * This cleans out unused clips */ public static function gc() { $sql = "DELETE FROM `clip` USING `clip` LEFT JOIN `video` ON `video`.`id` = `clip`.`id` " . "WHERE `video`.`id` IS NULL"; Dba::write($sql); } /** * create * This takes a key'd array of data as input and inserts a new clip entry, it returns the record id */ public static function insert($data) { $sql = "INSERT INTO `clip` (`id`,`artist`,`song`) " . "VALUES (?, ?, ?)"; Dba::write($sql, array($data['id'], $data['artist'], $data['song'])); return $data['id']; } // create /** * update * This takes a key'd array of data as input and updates a clip entry */ public static function update($data) { $sql = "UPDATE `clip` SET `artist` = ?, `song` = ? WHERE `id` = ?"; Dba::write($sql, array($data['artist'], $data['song'], $data['id'])); return true; } // update /** * format * this function takes the object and reformats some values */ public function format() { parent::format(); if ($this->artist) { $artist = new Artist($this->artist); $artist->format(); $this->f_artist = $artist->f_link; } if ($this->song) { $song = new Song($this->song); $song->format(); $this->f_song = $song->f_link; } return true; } //format } // Clip class