コード例 #1
0
ファイル: langvalues.php プロジェクト: ValenokPC/tabernacms
 /**
  * @return rad_query
  */
 protected function _getListQuery()
 {
     $q = new rad_query();
     if ($this->getState('code')) {
         $q->where('lnv_code=:code')->value(array('code' => $this->getState('code')));
     }
     if ($this->getState('group by')) {
         $q->group($this->getState('group by'));
     }
     if ($this->getState('select')) {
         $q->select($this->getState('select'));
     } else {
         $q->select('a.*');
     }
     if ($this->getState('from')) {
         $q->from($this->getState('from'));
     } else {
         $q->from(RAD . 'langvalues a');
     }
     if ($this->getState('id')) {
         $q->where('lnv_id=:id')->value(array('id' => (int) $this->getState('id')));
     }
     if ($this->getState('lang', $this->getState('lang_id'))) {
         if (is_array('lang')) {
             die('array=' . __FILE__ . 'line:' . __LINE__);
         } else {
             $q->where('lnv_lang=:lang')->value(array('lang' => $this->getState('lang', $this->getState('lang_id'))));
         }
     }
     if ($this->getState('value')) {
         $q->where('lnv_value=:value')->value(array('value' => $this->getState('value')));
     }
     if ($this->getState('order by', $this->getState('order'))) {
         $q->order($this->getState('order by', $this->getState('order')));
     } else {
         $q->order('lnv_code');
     }
     if ($this->getState('search.code')) {
         $q->where('lnv_code LIKE :searchcode')->value(array(':searchcode' => '%' . $this->getState('search.code') . '%'));
     }
     if ($this->getState('search')) {
         $q->where('lnv_code LIKE :search OR lnv_value LIKE :search')->value(array(':search' => '%' . $this->getState('search') . '%'));
     }
     return $q;
 }
コード例 #2
0
ファイル: referals.php プロジェクト: ValenokPC/tabernacms
 function _getListQuery()
 {
     $q = new rad_query();
     if ($this->getState('from')) {
         $q->from($this->getState('from'));
     } else {
         $q->from(RAD . 'referals a');
     }
     if ($this->getState('select')) {
         $q->select($this->getState('select'));
     } else {
         $q->select('a.*');
     }
     if ($this->getState('cookie')) {
         $q->where('rrf_cookie=:rrf_cookie')->value(array('rrf_cookie' => $this->getState('cookie')));
     }
     if ($this->getState('date.from')) {
         $date = is_int($this->getState('date.from')) ? date($this->config('date.format'), $this->getState('date.from')) : $this->getState('date.from');
         $q->where('rrf_date>=:dateFrom')->value(array('dateFrom' => $date));
     }
     if ($this->getState('date.to')) {
         $date = is_int($this->getState('date.to')) ? date($this->config('date.format'), $this->getState('date.to')) : $this->getState('date.to');
         $q->where('rrf_date<=:dateTo')->value(array('dateTo' => $date));
     }
     if ($this->getState('group', $this->getState('group by'))) {
         $q->group($this->getState('group', $this->getState('group by')));
         if ($this->getState('select.subcount')) {
             $q->select('count(a.rrf_id) as subcount');
         }
     }
     if ($this->getState('order', $this->getState('order by'))) {
         $q->order($this->getState('order', $this->getState('order by')));
     }
     return $q;
 }
コード例 #3
0
ファイル: image.php プロジェクト: ValenokPC/tabernacms
 /**
  * List query obgect
  * @param array $fields
  * @return rad_query
  */
 private function _getListQuery($fields = array())
 {
     $qb = new rad_query();
     if (isset($fields['select'])) {
         $qb->select($fields['select']);
     } else {
         $qb->select('*');
     }
     if (isset($fields['from'])) {
         $qb->from($fields['from']);
     } else {
         $qb->from(RAD . 'cat_images');
     }
     if (isset($fields['where'])) {
         $qb->where($fields['where']);
     }
     if (isset($fields['cat_id'])) {
         $qb->where('img_cat_id=:img_cat_id')->value(array('img_cat_id' => $fields['cat_id']));
     }
     if (isset($fields['img_main'])) {
         $qb->where('img_main=:img_main')->value(array('img_main' => $fields['img_main']));
     }
     if (isset($fields['order by'])) {
         $qb->order($fields['order by']);
     } else {
         $qb->order('img_main DESC');
     }
     if (isset($fields['group by'])) {
         $qb->group($fields['group by']);
     }
     return $qb;
 }
コード例 #4
0
ファイル: types.php プロジェクト: ValenokPC/tabernacms
 /**
  * List query
  *
  * @param array $fields
  * @param array $fk
  * @return rad_query
  */
 function getListQuery($fields, $fk = array())
 {
     $qb = new rad_query();
     if (isset($fields['select'])) {
         $qb->select($fields['select']);
     } else {
         $qb->select('*');
     }
     if (isset($fields['vl_id'])) {
         $qb->where('vl_id=:vl_id')->value(array('vl_id' => (int) $fields['vl_id']));
     }
     if (isset($fields['pid']) or isset($fields['vl_tre_id']) or isset($fields['tre_id'])) {
         $val = isset($fields['pid']) ? $fields['pid'] : isset($fields['vl_tre_id']) ? $fields['vl_tre_id'] : $fields['tre_id'];
         if (is_array($val)) {
             $treeIds = '';
             //Do NOT use IMPLODE HERE!!! For safe method use foreach and (int)
             foreach ($val as $key => $value) {
                 $treeIds .= (int) $value . ',';
             }
             $treeIds = substr($treeIds, 0, -1);
             $qb->where('vl_tre_id IN (' . $treeIds . ')');
         } else {
             $qb->where('vl_tre_id=:vl_tre_id')->value(array('vl_tre_id' => (int) $val));
         }
     }
     if (isset($fields['vl_name']) or isset($fields['name'])) {
         $val = isset($fields['vl_name']) ? $fields['vl_name'] : $fields['name'];
         $qb->where('vl_name=:vl_name')->value(array('vl_name' => $val));
     }
     if (isset($fields['vl_type_in']) or isset($fields['type_in'])) {
         $val = isset($fields['vl_type_in']) ? $fields['vl_type_in'] : $fields['type_in'];
         $qb->where('vl_type_in=:vl_type_in')->value(array('vl_type_in' => $val));
     }
     if (isset($fields['vl_type_print']) or isset($fields['type_print'])) {
         $val = isset($fields['vl_type_print']) ? $fields['vl_type_print'] : $fields['type_print'];
         $qb->where('vl_type_print=:vl_type_print')->value(array('vl_type_print' => $val));
     }
     if (isset($fields['vl_measurement_id']) or isset($fields['measurement_id'])) {
         $val = isset($fields['vl_measurement_id']) ? $fields['vl_measurement_id'] : $fields['measurement_id'];
         $qb->where('vl_measurement_id=:vl_measurement_id')->value(array('vl_measurement_id' => $val));
     }
     if (isset($fields['active']) or isset($fields['vl_active'])) {
         $val = isset($fields['active']) ? $fields['active'] : $fields['vl_active'];
         $qb->where('vl_active=:vl_active')->value(array('vl_active' => $val));
     }
     if (isset($fk['measurement'])) {
         $qb->join('LEFT', RAD . 'measurement as m on m.ms_id=a.vl_measurement_id');
     }
     if (isset($fk['ct_showing']) and isset($fields['cts_show'])) {
         $val = isset($fk['ct_showing']) ? $fk['ct_showing'] : $fields['cts_show'];
         $qb->join('LEFT', RAD . 'ct_showing as cts on cts.cts_vl_id=a.vl_id WHERE cts_show=:cts_show')->value(array('cts_show' => $val));
     }
     if (!empty($fields['filter'])) {
         $qb->where('vl_filter=1');
         $qb->join('RIGHT', RAD . 'cat_val_values ON vv_name_id=vl_id');
         if (!empty($fields['cat_id'])) {
             if (is_array($fields['cat_id'])) {
                 $catIds = array();
                 foreach ($fields['cat_id'] as $idN => $idV) {
                     $catIds[] = (int) $idV;
                 }
                 $qb->where('vv_cat_id IN (' . implode(',', $catIds) . ')');
             } else {
                 $qb->where('vv_cat_id=:cat_id')->value(array('cat_id' => $fields['cat_id']));
             }
         }
     }
     if (isset($fields['order'])) {
         $qb->order($fields['order']);
     } else {
         $qb->order('a.vl_position');
     }
     if (!empty($fields['group by'])) {
         $qb->group($fields['group by']);
     }
     $qb->from(RAD . 'cat_val_names a');
     return $qb;
 }
コード例 #5
0
ファイル: comments.php プロジェクト: ValenokPC/tabernacms
 private function _getListQuery()
 {
     $qb = new rad_query();
     if ($this->getState('from')) {
         $qb->from($this->getState('from'));
     } else {
         $qb->from(RAD . 'comments a');
     }
     if ($this->getState('select')) {
         $qb->select($this->getState('select'));
     } else {
         $qb->select('*');
     }
     if ($this->getState('join.news')) {
         $qb->join('LEFT', RAD . 'news ON nw_id=a.rcm_item_id AND rcm_type="' . self::TYPE_NEWS . '"');
     }
     if ($this->getState('join.articles')) {
         $qb->join('LEFT', RAD . 'articles ON art_id=a.rcm_item_id AND rcm_type="' . self::TYPE_ARTICLES . '"');
     }
     if ($this->getSTate('join.orders')) {
         $qb->join('LEFT', RAD . 'orders o ON o.order_id=a.rcm_item_id AND rcm_type="' . self::TYPE_ORDER . '"');
     }
     if ($this->getSTate('join.products')) {
         $qb->join('LEFT', RAD . 'catalog c ON c.cat_id=a.rcm_item_id AND rcm_type="' . self::TYPE_PRODUCT . '"');
     }
     if ($this->getState('order', $this->getState('order by'))) {
         $qb->order($this->getState('order', $this->getState('order by')));
     }
     if ($this->getState('group')) {
         $qb->group($this->getState('group'));
     }
     if ($this->getState('rcm_item_id', $this->getState('item_id'))) {
         $qb->where('rcm_item_id=:item_id')->value(array('item_id' => $this->getState('rcm_item_id', $this->getState('item_id'))));
     }
     if ($this->getState('rcm_active', $this->getState('active'))) {
         $qb->where('rcm_active=:rcm_active')->value(array('rcm_active' => $this->getState('rcm_active', $this->getState('active'))));
     }
     if ($this->getState('rcm_type', $this->getState('type'))) {
         $qb->where('rcm_type=:rcm_type')->value(array('rcm_type' => $this->getState('rcm_type', $this->getState('type'))));
     }
     if ((int) $this->getState('rcm_id', $this->getState('id'))) {
         $qb->where('rcm_id=:id')->value(array('id' => (int) $this->getState('rcm_id', $this->getState('id'))));
     }
     return $qb;
 }
コード例 #6
0
ファイル: table.php プロジェクト: ValenokPC/tabernacms
 /**
  * @return rad_query
  */
 protected function getListQuery($fields)
 {
     $qb = new rad_query();
     if (isset($fields['from'])) {
         $qb->from($fields['from']);
     } else {
         $qb->from($this->_tablename);
     }
     $struct = $this->_struct_name;
     $struct = new $struct();
     foreach ($struct->getKeys('', true) as $id => $field) {
         if (isset($fields[$field])) {
             $qb->where($field . '=:' . $field)->value(array($field => $fields[$field]));
         }
     }
     //foreach
     unset($struct);
     if (isset($fields['select'])) {
         $qb->select($fields['select']);
     } else {
         $qb->select('*');
     }
     if (isset($fields['where'])) {
         $qb->where($fields['where']);
     }
     if (isset($fields['order by'])) {
         $qb->order($fields['order by']);
     }
     if (isset($fields['having'])) {
         $qb->having($fields['having']);
     }
     if (isset($fields['group by'])) {
         $qb->group($fields['group by']);
     }
     if (isset($fields['left join'])) {
         $qb->join('LEFT', $fields['left join']);
     }
     if (isset($fields['inner join'])) {
         $qb->join('INNER', $fields['inner join']);
     }
     if (isset($fields['order'])) {
         $qb->order($fields['order']);
     }
     $struct_name = $this->_struct_name;
     $tmp_struct = new $struct_name();
     if (isset($fields[$tmp_struct->getPrimaryKey()])) {
         $pk = $tmp_struct->getPrimaryKey();
         $qb->where($pk . '=' . (int) $fields[$pk]);
     }
     return $qb;
 }
コード例 #7
0
ファイル: catalog.php プロジェクト: ValenokPC/tabernacms
 /**
  * Gets the query
  *
  * @return rad_query
  */
 function _getListQuery()
 {
     $qb = new rad_query();
     if ($this->getState('select')) {
         $qb->select($this->getState('select'));
     } else {
         $qb->select('a.*');
     }
     if ($this->getState('from')) {
         $qb->from($this->getState('from'));
     } else {
         $qb->from(RAD . 'catalog a');
     }
     if ($this->getState('id')) {
         $qb->where('cat_id=:cat_id')->value(array('cat_id' => $this->getState('id')));
     }
     if ($this->getState('order by')) {
         $qb->order($this->getState('order by'));
     }
     if ($this->getState('cat_code')) {
         $qb->where('cat_code=:cat_code')->value(array('cat_code' => $this->getState('cat_code')));
     }
     if ($this->getState('tre_id')) {
         if (is_array($this->getState('tre_id'))) {
             $treIds = array();
             foreach ($this->getState('tre_id') as $key => $treId) {
                 $treIds[] = (int) $treId;
             }
             $treIds = implode(',', $treIds);
             $qb->join('INNER', RAD . 'cat_in_tree cit ON cit.cit_cat_id=a.cat_id AND cit_tre_id IN (' . $treIds . ')');
         } else {
             $qb->join('INNER', RAD . 'cat_in_tree cit ON cit.cit_cat_id=a.cat_id AND cit_tre_id=:tre_id');
             $qb->value(array('tre_id' => $this->getState('tre_id')));
         }
     }
     if ($this->getState('join.tree')) {
         $qb->join('LEFT', RAD . 'cat_in_tree cit_j ON cit_j.cit_cat_id=a.cat_id');
         $qb->join('LEFT', RAD . 'tree cit_jt ON cit_jt.tre_id=cit_j.cit_tre_id');
         $qb->select('cit_jt.*');
     }
     if ($this->getState('active')) {
         $qb->where('cat_active=1');
     }
     if ($this->getState('group by')) {
         $qb->group($this->getState('group by'));
     }
     if ($this->getState('currency')) {
         $qb->join('INNER', RAD . 'currency cur ON cur.cur_id=a.cat_currency_id')->join('INNER', RAD . 'currency cr ON cr.cur_id=:currency')->value(array('currency' => $this->getState('currency')))->select('(a.cat_cost*cur.cur_cost)/cr.cur_cost AS price');
     }
     if ($this->getState('join.mainimage')) {
         $typeJoin = $this->getState('only.withimages') ? 'INNER' : 'LEFT';
         $qb->join($typeJoin, RAD . 'cat_images i ON img_cat_id=cat_id AND img_main=1');
         $qb->select('i.img_filename');
     }
     if ($this->getState('lang', $this->getState('lang_id'))) {
         $qb->where('a.cat_lngid=:cat_lngid')->value(array('cat_lngid' => $this->getState('lang', $this->getState('lang_id'))));
     }
     if ($this->getState('cat_usercreated')) {
         $qb->where('a.cat_usercreated=:usercreated')->value(array('usercreated' => $this->getState('cat_usercreated')));
     }
     if ($this->getState('where')) {
         $qb->where($this->getState('where'));
     }
     return $qb;
 }
コード例 #8
0
ファイル: order.php プロジェクト: ValenokPC/tabernacms
 private function _getListQuery()
 {
     $q = new rad_query();
     if ($this->getState('select')) {
         $q->select($this->getState('select'));
     } else {
         $q->select('*');
     }
     if ($this->getState('where')) {
         $q->where($this->getState('where'));
     }
     if ($this->getState('order by')) {
         $q->order($this->getState('order by'));
     }
     if ($this->getState('group by')) {
         $q->group($this->getState('group by'));
     }
     if ($this->getState('pid')) {
         $q->where('order_status = :order_status')->value(array('order_status' => (int) $this->getState('pid')));
     }
     if ($this->getState('order_type')) {
         $q->where('order_type = :order_type')->value(array('order_type' => (int) $this->getState('order_type')));
     }
     if ($this->getState('user_id')) {
         $q->where('order_userid = :order_userid')->value(array('order_userid' => (int) $this->getState('user_id')));
     }
     if ($this->getState('lang', $this->getState('lang_id'))) {
         $q->where('order_langid=:lang_id')->value(array('lang_id' => (int) $this->getState('lang', $this->getState('lang_id'))));
     }
     $q->from(RAD . 'orders');
     return $q;
 }