private static function getAllOnSectionOrCategory($field, $value, $order, $offset) { $select = self::getBaseSelect(); $select->where("`{$field}` = " . self::$db->getSQ(), array($value))->order("date", $order); $data = self::$db->select($select); $articles = ObjectDB::buildMultiple(__CLASS__, $data); return $articles; }
public static function getAllOnArticleID($article_id) { $select = new Select(self::$db); $select->from(self::$table, "*")->where("`article_id` = " . self::$db->getSQ(), array($article_id))->order("date"); $comments = ObjectDB::buildMultiple(__CLASS__, self::$db->select($select)); $comments = ObjectDB::addSubObject($comments, "UserDB", "user", "user_id"); return $comments; }
public static function getImgOnID($id) { $select = new Select(self::$db); $select->from(self::$table, "*")->where("`product_id` = " . self::$db->getSQ(), array($id)); $data = self::$db->select($select); $images = ObjectDB::buildMultiple(__CLASS__, $data); return $images; }
public static function getAdminShow() { $data = self::$db->getResult("select c.*, s.title as section from " . Config::DB_PREFIX . "category c left join " . Config::DB_PREFIX . "section s on c.section_id=s.id"); $category = ObjectDB::buildMultiple(__CLASS__, $data); foreach ($category as $cat) { $cat->postAdminHandling(); } return $category; }
public static function getStudentsOnGroupID($group_id) { $select = new Select(self::$db); $select->from(self::$table, "*")->where("`group_id` = ?", array($group_id)); $data = self::$db->select($select); $students = ObjectDB::buildMultiple(__CLASS__, $data); //foreach ($groups as $g) $g->postHandling(); return $students; }
public static function getAllOnArticleID($article_id) { $select = new Select(self::$db); $select->from(self::$table, "*")->where("`article_id` = " . self::$db->getSQ(), array($article_id))->order("date"); //сортировка по дате $comments = ObjectDB::buildMultiple(__CLASS__, self::$db->select($select)); $comments = ObjectDB::addSubObject($comments, "UserDB", "user", "user_id"); //добавление к коментариям данных пользователя return $comments; }
public static function getItemsOnView($view) { $select = new Select(self::$db); $select->from(self::$table, "*")->where("`view_id` = ?", array($view)); $data = self::$db->select($select); $items = ObjectDB::buildMultiple(__CLASS__, $data); foreach ($items as $item) { $item->postHandling(); } return $items; }
public static function getItems() { $select = new Select(self::$db); $select->from(self::$table, array("s.*", "p.img"), "s")->join("INNER", "product", "p", "s.product_id = p.id"); $data = self::$db->select($select); $slider = ObjectDB::buildMultiple(__CLASS__, $data); foreach ($slider as $slide) { $slide->postHandling(); } return $slider; }
public static function getItems() { if (isset($_SESSION["basket"])) { $items = ObjectDB::buildMultiple("ProductDB", $_SESSION["basket"]); foreach ($items as $item) { $item->img = Config::DIR_IMG_PRODUCT . $item->img; } return $items; } return false; }
public static function getGroupsOnTeacherID($id) { $select = new Select(self::$db); $select->from(self::$table, "*")->where("`teacher_id` = ?", array($id)); $data = self::$db->select($select); $groups = ObjectDB::buildMultiple(__CLASS__, $data); foreach ($groups as $g) { $g->postHandling(); } return $groups; }
public function loadOnSectionID($section_id, $type) { $select = new Select(); $select->from(self::$table, "*")->where("`type` = " . self::$db->getSQ(), array($type))->where("`latest` = " . self::$db->getSQ(), array(1))->rand(); $data_1 = self::$db->select($select); $select = new Select(); $select->from(self::$table, "*")->where("`type` = " . self::$db->getSQ(), array($type)); if ($section_id) { $select->whereFIS("section_ids", $section_id); } $select->rand(); $data_2 = self::$db->select($select); $data = array_merge($data_1, $data_2); if (count($data) == 0) { $select = new Select(); $select->from(self::$table, "*")->where("`type` = " . self::$db->getSQ(), array($type))->rand(); $data = self::$db->select($select); } $data = ObjectDB::buildMultiple(__CLASS__, $data); uasort($data, array(__CLASS__, "compare")); $first = array_shift($data); $this->load($first->id); }
protected static function searchObjects($select, $class, $fields, $words, $min_len) { $words = mb_strtolower($words); $words = preg_replace("/ {2,}/", " ", $words); if ($words == "") { return array(); } $array_words = explode(" ", $words); $temp = array(); foreach ($array_words as $value) { if (strlen($value) >= $min_len) { $temp[] = $value; } } $array_words = $temp; if (count($array_words) == 0) { return array(); } foreach ($array_words as $value) { $where = ""; $params = array(); for ($i = 0; $i < count($fields); $i++) { $where .= "`" . $fields[$i] . "` LIKE " . self::$db->getSQ(); $params[] = "%{$value}%"; if ($i + 1 != count($fields)) { $where .= "OR"; } } $select->where("({$where})", $params, true); } $results = self::$db->select($select); if (!$results) { return array(); } $results = ObjectDB::buildMultiple($class, $results); foreach ($results as $result) { for ($j = 0; $j < count($fields); $j++) { $result->{$fields}[$j] = mb_strtolower(strip_tags($result->{$fields}[$j])); } $data[$result->id] = $result; $data[$result->id]->relevant = self::getRelevantForSearch($result, $fields, $array_words); } uasort($data, array("AbstractObjectDB", "compareRelevant")); return $data; }
private static function getAllOnSectionOrCategory($field, $value, $order, $offset) { $select = self::getBaseSelect(); //получени всех полей таблицы $select->where("`{$field}` = " . self::$db->getSQ(), array($value))->order("date", $order); //сортировка направлениее из параметра $data = self::$db->select($select); //ош $articles = ObjectDB::buildMultiple(__CLASS__, $data); return $articles; }
public static function getAdminShow() { $data = self::$db->getResult("select p.id, p.title, p.img, p.video, c.title as category, b.title as brand, p.price, p.full_text, p.meta_desc, p.meta_key, p.available\r\n\t\t\tfrom " . Config::DB_PREFIX . "product p \r\n\t\t\tleft join " . Config::DB_PREFIX . "category c on p.category_id=c.id\r\n\t\t\tleft join " . Config::DB_PREFIX . "brand b on p.brand_id=b.id"); $items = ObjectDB::buildMultiple(__CLASS__, $data); foreach ($items as $item) { $item->postAdminHandling(); } return $items; }