Ejemplo n.º 1
0
 /**
  * Get all hosts
  *@return array Set of Host objects
  */
 public static function getAllHosts($cacheMinutes = null)
 {
     $hosts = array();
     $sql = MySqlDbManager::getQueryObject();
     $sql->exec("SELECT * FROM `" . Tbl::get('TBL_HOSTS', 'Host') . "`", $cacheMinutes);
     while (($host_data = $sql->fetchRecord()) != false) {
         $h = new Host();
         Host::setData($host_data, $h);
         $hosts[] = $h;
     }
     return $hosts;
 }
Ejemplo n.º 2
0
 public static function getLanguageHosts(Language $lang)
 {
     $hosts = array();
     $sql = MySqlDbManager::getQueryObject();
     $sql->exec("SELECT h.* FROM `" . Tbl::get('TBL_PAGE_INFO', 'PageInfo') . "` pi \n\t\t\t\t\tLEFT JOIN `" . Host::TBL_HOSTS . "` h ON h.id = pi.host_id \n\t\t\t\t\tWHERE pi.lang_id='{$lang->id}' AND pi.host_id IS NOT NULL\n\t\t\t\t\tGROUP BY h.id");
     $hosts_data = $sql->fetchRecords();
     foreach ($hosts_data as $host_data) {
         $host = new Host();
         Host::setData($host_data, $host);
         $hosts[] = $host;
     }
     return $hosts;
 }
Ejemplo n.º 3
0
 public static function getLanguageHosts(Language $lang, $cacheMinutes = null)
 {
     $hosts = array();
     $sql = MySqlDbManager::getQueryObject();
     $qb = new QueryBuilder();
     $qb->select(new Field('*', 'h'))->from(Tbl::get('TBL_PAGE_INFO', 'PageInfo'), 'pi')->leftJoin(Tbl::get('TBL_HOSTS', 'Host'), 'h', $qb->expr()->equal(new Field('id', 'h'), new Field('host_id', 'pi')))->where($qb->expr()->equal(new Field('lang_id', 'pi'), $lang->id))->andWhere($qb->expr()->isNotNull(new Field('host_id', 'pi')))->groupBy(new Field('id', 'h'));
     $sql->exec($qb->getSQL(), $cacheMinutes);
     $hosts_data = $sql->fetchRecords();
     foreach ($hosts_data as $host_data) {
         $host = new Host();
         Host::setData($host_data, $host);
         $hosts[] = $host;
     }
     return $hosts;
 }
 /**
  * Get all possible pairs of Host Language
  *
  * @return array 2D array key is host_language_id with "host" and "language" keys with values as corresponding objects 
  */
 public static function getAllPairs($cacheMinutes = null)
 {
     $pairs = array();
     $sql = MySqlDbManager::getQueryObject();
     $sql->exec("SELECT *, hl.id host_lang_id FROM " . Tbl::get('TBL_HOST_LANGUAGE') . " hl\n\t\t\t\t\tLEFT JOIN `" . Tbl::get("TBL_LANGUAGES", "Language") . "` l ON hl.lang_id=l.id\n\t\t\t\t\tLEFT JOIN `" . Tbl::get("TBL_HOSTS", "Host") . "` h ON hl.host_id=h.id", $cacheMinutes);
     while (($row = $sql->fetchRecord()) != false) {
         $host = new Host();
         $language = new Language();
         $row["id"] = $row["lang_id"];
         Language::setData($row, $language);
         $row["id"] = $row["host_id"];
         Host::setData($row, $host);
         $pairs[$row["host_lang_id"]] = array("host" => $host, "language" => $language);
     }
     return $pairs;
 }
Ejemplo n.º 5
0
 /**
  * Get all hosts
  *@return array Set of Host objects
  */
 public static function getAllHosts(MysqlPager $pager = null, $cacheMinutes = null)
 {
     $hosts = array();
     $sql = MySqlDbManager::getQueryObject();
     $qb = new QueryBuilder();
     $qb->select(new Field('*'))->from(Tbl::get('TBL_HOSTS', 'Host'));
     if ($pager !== null) {
         $sql = $pager->executePagedSQL($qb->getSQL(), $cacheMinutes);
     } else {
         $sql->exec($qb->getSQL(), $cacheMinutes);
     }
     while (($host_data = $sql->fetchRecord()) != false) {
         $h = new Host();
         Host::setData($host_data, $h);
         $hosts[] = $h;
     }
     return $hosts;
 }
Ejemplo n.º 6
0
 /**
  * Get all possible pairs of Host Language
  *
  * @return array 2D array key is host_language_id with "host" and "language" keys with values as corresponding objects 
  */
 public static function getAllPairs($cacheMinutes = null)
 {
     $pairs = array();
     $sql = MySqlDbManager::getQueryObject();
     $qb = new QueryBuilder();
     $qb->select(array(new Field('*'), new Field('id', 'hl', 'host_lang_id')))->from(Tbl::get('TBL_HOST_LANGUAGE'), 'hl')->leftJoin(Tbl::get("TBL_LANGUAGES", "Language"), 'l', $qb->expr()->equal(new Field('lang_id', 'hl'), new Field('id', 'l')))->leftJoin(Tbl::get("TBL_HOSTS", "Host"), 'h', $qb->expr()->equal(new Field('host_id', 'hl'), new Field('id', 'h')));
     $sql->exec($qb->getSQL(), $cacheMinutes);
     while (($row = $sql->fetchRecord()) != false) {
         $host = new Host();
         $language = new Language();
         $row["id"] = $row["lang_id"];
         Language::setData($row, $language);
         $row["id"] = $row["host_id"];
         Host::setData($row, $host);
         $pairs[$row["host_lang_id"]] = array("host" => $host, "language" => $language);
     }
     return $pairs;
 }