Example #1
0
 /** Gets TLangPOS object by property $property_name with value $property_value.
  * @return TLangPOS or NULL in case of error
  */
 public static function getLangPOS($property_name, $property_value, $page_obj = NULL)
 {
     global $LINK_DB;
     $query = "SELECT * FROM lang_pos WHERE lang_id is not NULL and pos_id is not NULL and `{$property_name}`='{$property_value}' order by id";
     $result = $LINK_DB->query_e($query, "Query failed in " . __METHOD__ . " in file <b>" . __FILE__ . "</b>, string <b>" . __LINE__ . "</b>");
     if ($LINK_DB->query_count($result) == 0) {
         return NULL;
     }
     $lang_pos_arr = array();
     while ($row = $result->fetch_object()) {
         $lang = TLang::getByID($row->lang_id);
         $pos = TPOS::getByID($row->pos_id);
         if (NULL == $lang || NULL == $pos) {
             return NULL;
         }
         if ($page_obj == NULL) {
             $page_obj = TPage::getByID($row->page_id);
         }
         $lang_pos = new TLangPOS($row->id, $page_obj, $lang, $pos, $row->etymology_n, $row->lemma);
         $lang_pos->meaning = TMeaning::getByLangPOS($row->id, $lang_pos);
         $lang_pos_arr[] = $lang_pos;
     }
     return $lang_pos_arr;
 }