Разработка web-сайта о кафе, барах и ресторанах города Челябинска
Дипломная работа - Компьютеры, программирование
Другие дипломы по предмету Компьютеры, программирование
t1.showed, true);
}
groupBy(t1.id);">$q->groupBy(t1.id);
$q->limit(1);
$items = $q->get()->result();(count($items)>0) {
$item = $items[0];$item;
} else { false;
}
}
/**
* выборка записи по полю и значению для админки
*
* @param integer $field поля таблице для выборки
* @param string $value значение для выборки
* @param boolean $separate_lang признак будут ли разделены языки? иначе будет выбран текущий
*
* @return object
*/function getByField($field, $value=true, $separate_lang=false)
{
$q = $this->db->select()->from($this->descriptor->getTable(), array());(!$separate_lang && $this->descriptor->multi_lang_field) {
join($this->descriptor->getTable()._content,t1.id=t2..$this->descriptor->multi_lang_field,array());">$q->join($this->descriptor->getTable()._content, t1.id=t2..$this->descriptor->multi_lang_field, array());
join(langs,"t2.lang_id=t3.id",array());">$q->join(langs, "t2.lang_id=t3.id", array());
where(t3.short,$this->Lang->default_lang);">$q->where(t3.short, $this->Lang->default_lang);
whereIsNotNull(t3.short);">$q->whereIsNotNull(t3.short);
$q->escape(false)->column(t3.*, t2.*)->escape(true);
}
$q->escape(false)->column(x(point) as point_x, y(point) as point_y, t1.*)->escape(true);
$q->where(t1..$field, $value);(!$this->obj->is_admin && $this->load->database_original()->field_exists(showed, $this->descriptor->getTable())) {
where(t1.showed,true);">$q->where(t1.showed, true);
}
groupBy(t1.id);">$q->groupBy(t1.id);
$q->limit(1);
$items = $q->get()->result();(count($items)>0) {
$item = $items[0];
// TODO: убрать бы id...($separate_lang && $field==id && $this->descriptor->multi_lang_field) {
$q = $this->db->select()->from($this->descriptor->getTable()._content, array());
escape(false)->column("t2.shortaslang_short_name,t1.*")->escape(true);">$q->escape(false)->column("t2.short as lang_short_name, t1.*")->escape(true);
join(langs,"t1.lang_id=t2.id",array());">$q->join(langs, "t1.lang_id=t2.id", array());
$q->where(t1..$this->descriptor->multi_lang_field, $value);
$langs_values = $q->get()->result();(count($langs_values)>0) {($langs_values as $values) {($values as $key=>$val) {(isset($item->{$key})) {(is_array($item->{$key})) {
$item->{$key}[$values->lang_short_name] = $val;
}
} else {
$item->{$key} = array($values->lang_short_name => $val);
}
}
}
}
}($separate_lang && $field==id) {($this->descriptor->common_fields as $name=>$field) {($field[type])
{multiselect:
$q = $this->db->select()->from($field[table], array());
$q->escape(false)->column(t1.*)->escape(true);
$q->where(t1..$field[inner_field], $value);
$item->{$name} = $q->get()->result();;
}
}
}$item;
} else {false;
}
}
/**
* условие для поиска
*
* @param string $tag_slug slug тэга
*
* @return array
*/function _sub_search($q, $search)
{
$q->where()
like(t2.name,$search[q])">>like(t2.name, $search[q])
>where(or)
like(t2.short,$search[q])">>like(t2.short, $search[q])
>where(or)
like(t2.full,$search[q])">>like(t2.full, $search[q])
>where(or)
like(t2.advanced_services,$search[q])">>like(t2.advanced_services, $search[q])
>where(or)
like(t2.phones,$search[q])">>like(t2.phones, $search[q])
>where(or)
like(t2.programm,$search[q])">>like(t2.programm, $search[q])
>where(or)
like(t2.title,$search[q])">>like(t2.title, $search[q])
>where(or)
like(t2.keywords,$search[q])">>like(t2.keywords, $search[q])
>where(or)
like(t2.description,$search[q])">>like(t2.description, $search[q])
>where(or)
like(t1.address,$search[q])">>like(t1.address, $search[q])
>end();$q;
}
/**
* поиск фирм
*
* @param array $search условия поиска
*
* @return array
*/function search($search, $page=0)
{(!$search[q])array(array(),0,0);
$q = $this->db->select()->from($this->descriptor->getTable(), array());($this->descriptor->multi_lang_field) {
join($this->descriptor->getTable()._content,t1.id=t2..$this->descriptor->multi_lang_field,array());">$q->join($this->descriptor->getTable()._content, t1.id=t2..$this->descriptor->multi_lang_field, array());
join(langs,"t2.lang_id=t3.id",array());">$q->join(langs, "t2.lang_id=t3.id", array());
where(t3.short,$this->Lang->default_lang);">$q->where(t3.short, $this->Lang->default_lang);
whereIsNotNull(t3.short);">$q->whereIsNotNull(t3.short);
$q->escape(false)->column(t3.*, t2.*)->escape(true);
}
join(firms_tags,"t1.id=t4.firm_id",array());">$q->join(firms_tags, "t1.id=t4.firm_id", array());
join(tags,"t5.id=t4.tag_id",array());">$q->join(tags, "t5.id=t4.tag_id", array());
$q->escape(false)->column(x(point) as point_x, y(point) as point_y, t1.*)->escape(true);
escape(false)->column(round(avg(t6.rate))asrate,count(distinctt6.id)ascount_rate)->escape(true);">$q->escape(false)->column(round(avg(t6.rate)) as rate,count(distinct t6.id) as count_rate)->escape(true);
join(firms_rates,"t1.id=t6.firm_id",array());">$q->join(firms_rates, "t1.id=t6.firm_id", array());
escape(false)->column(t7.imgascat_img,t8.nameascat_name)->escape(true);">$q->escape(false)->column(t7.img as cat_img,t8.name as cat_name)->escape(true);
join(cats,"t7.id=t1.cat_id",array());">$q->join(cats, "t7.id=t1.cat_id", array());
join(cats_content,t7.id=t8.cat_id,array());">$q->join(cats_content, t7.id=t8.cat_id, array());
join(langs,"t8.lang_id=t9.id",array());">$q->join(langs, "t8.lang_id=t9.id", array());
where(t1.showed,true);">$q->where(t1.showed, true);
where(t5.showed,true);">$q->where(t5.showed, true);
$this->_sub_search($q, $search);
escape(false)->orderBy(t1.id)->escape(true);">$q->escape(false)->orderBy(t1.id)->escape(true);
groupBy(t1.id);">$q->groupBy(t1.id);
$q->limit($this->count_per_page, $this->count_per_page*$page);
$items = $q->get()->result();
// общее число записей
$q = $this->db->select()->from($this->descriptor->getTable(), array());
join($this->descriptor->getTable()._content,t1.id=t2..$this->descriptor->multi_lang_field,array());">$q->join($this->descriptor->getTable()._content, t1.id=t2..$this->descriptor->multi_lang_field, array());
join(langs,"t2.lang_id=t3.id",array());">$q->join(langs, "t2.lang_id=t3.id", array());
where(t3.short,$this->Lang->default_lang);">$q->where(t3.short, $this->Lang->default_lang);
whereIsNotNull(t3.short);">$q->whereIsNotNull(t3.short);
join(firms_tags,"t1.id=t4.firm_id",array());">$q->join(firms_tags, "t1.id=t4.firm_id", array());
join(tags,"t5.id=t4.tag_id",array());">$q->join(tags, "t5.id=t4.tag_id", ar