id = $params['id']; } $this->name = $params['name']; $this->title = $params['title']; $this->desc = $params['desc']; } } public static function find($id = null,$start) { if($id) { $sql = "SELECT * FROM video_events WHERE id=$id"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); return new Video_event($row); } else { $sql = "select * from video_events order by id limit $start,10"; $events = array(); $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $events[] = new Video_event($row); } } return $events; } public function save() { $sql = "INSERT INTO video_events(`name`,`title`,`desc`)VALUES('$this->name','$this->title','$this->desc')"; mysql_query($sql) or die(mysql_error()); } public function edit($id) { $sql = "UPDATE video_events SET `name`='$this->name', `title`='$this->title', `desc`='$this->desc' WHERE `id`='$id'"; mysql_query($sql) or die(mysql_error()); } public function delete() { $sql = "DELETE FROM video_events where id=$this->id" ; mysql_query($sql); } public function id() { return $this->id; } public function name() { return $this->name; } public function title() { return $this->title; } public function desc() { return $this->desc; } public static function Count() { $sql = "SELECT count(id) AS v_event_count from video_events"; $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($result); return $row['v_event_count']; } } ?>