timeInSeconds; } function getName() { return $this->name; } function getVideos_id() { return $this->videos_id; } function setTimeInSeconds($timeInSeconds) { $this->timeInSeconds = $timeInSeconds; } function setName($name) { $this->name = $name; } function setVideos_id($videos_id) { $this->videos_id = $videos_id; } static function deleteAllFromVideo($videos_id) { global $global; if (!empty($videos_id)) { $sql = "DELETE FROM " . static::getTableName() . " "; $sql .= " WHERE videos_id = ?"; $global['lastQuery'] = $sql; //_error_log("Delete Query: ".$sql); return sqlDAL::writeSql($sql,"i",array($videos_id)); } return false; } static function getAllFromVideo($videos_id) { global $global; $sql = "SELECT * FROM " . static::getTableName() . " WHERE videos_id = ? "; //$sql .= self::getSqlFromPost(); $res = sqlDAL::readSql($sql,"i",array($videos_id)); $fullData = sqlDAL::fetchAllAssoc($res); sqlDAL::close($res); $rows = array(); if ($res!=false) { foreach ($fullData as $row) { $rows[] = $row; } } else { die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } return $rows; } static function getAll() { global $global; $sql = "SELECT b.*, title, filename FROM " . static::getTableName() . " b LEFT JOIN videos v on v.id = videos_id WHERE 1=1 "; $sql .= self::getSqlFromPost(); $res = sqlDAL::readSql($sql); $fullData = sqlDAL::fetchAllAssoc($res); sqlDAL::close($res); $rows = array(); if ($res!=false) { foreach ($fullData as $row) { $rows[] = $row; } } else { die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } return $rows; } public function save() { // make sure that will be only one bookmark for each time $row = self::getFromTime($this->getVideos_id(), $this->getTimeInSeconds()); if(!empty($row)){ $this->id = $row['id']; } parent::save(); } static protected function getFromTime($videos_id, $timeInSeconds) { global $global; $sql = "SELECT * FROM " . static::getTableName() . " WHERE videos_id = ? AND timeInSeconds = ? LIMIT 1"; // I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about $res = sqlDAL::readSql($sql,"ii",array($videos_id, $timeInSeconds)); $data = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($res) { $row = $data; } else { $row = false; } return $row; } }