Example #1
0
 function get_short_info($id = false, $current_language = 'English')
 {
     #
     $language = new Language();
     is_numeric($current_language) ? $language->get_by_id($current_language) : $language->get_by_name($current_language);
     #svazivaet nutrition s vibranim language
     if ($id) {
         $this->get_by_id($id);
         $this->language->include_join_fields()->get_iterated();
     } else {
         $full_list = new Nutrition();
         $full_list->select('id, tagname')->where('Group_List', 3)->get_iterated();
         #создает объектную модель данных для одбращения к данным через свойства объекта
         $this->select('id, tagname, value, units')->where('group_list', 3)->get();
         foreach ($this as $nutrition) {
             $this->data->{strtolower($nutrition->tagname)} = array('id' => $nutrition->id, 'value' => $nutrition->value, 'units' => $nutrition->units);
         }
         #добавляет нулевые значения к отсутствующим данным
         foreach ($full_list as $elem) {
             if (!isset($this->data->{strtolower($elem->tagname)})) {
                 $this->data->{strtolower($elem->tagname)} = array('id' => $elem->id, 'value' => '~', 'units' => '');
             }
         }
         $this->id = null;
     }
 }