예제 #1
0
 /**
  * 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;
 }
예제 #2
0
 /**
  * Gets 3dImages
  * @return multitype:struct_corecatalog_cat_3dimages
  */
 public function getItems()
 {
     $q = new rad_query();
     $q->select('*')->from(RAD . 'cat_3dimages');
     if ($this->getState('cat_id')) {
         $q->where('img_cat_id=:cat_id')->value(array('cat_id' => $this->getState('cat_id')));
     }
     $res = $this->queryAll($q->toString(), $q->getValues());
     $result = array();
     if (count($res)) {
         foreach ($res as $id) {
             $result[] = new struct_corecatalog_cat_3dimages($id);
         }
     }
     return $result;
 }
예제 #3
0
 private function _getListQuery($options, $fk = array())
 {
     $qb = new rad_query();
     if (isset($options['from'])) {
         $qb->from($options['from']);
     } else {
         $qb->from(RAD . 'votes a');
     }
     if (isset($options['select'])) {
         $qb->select($options['select']);
     } else {
         $qb->select('a.*');
     }
     if (isset($options['order by'])) {
         $qb->order($options['order by']);
     } else {
         $qb->order('a.vt_position');
     }
     if (isset($options['pid'])) {
         $val = $options['pid'];
         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('a.vt_treid IN (' . $treeIds . ')');
         } else {
             $qb->where('a.vt_treid=' . (int) $val);
         }
     }
     if (isset($options['vt_id'])) {
         $qb->where('a.vt_id=' . (int) $options['vt_id']);
     }
     if (isset($options['lang'])) {
         $qb->where('a.vt_lngid=' . (int) $options['lang']);
     }
     if (isset($options['!vta_hash'])) {
         $qb->join('LEFT', RAD . 'votes_answers va on vta_vtid=vt_id and va.vta_hash="' . $options['!vta_hash'] . '"');
         $qb->where('ISNULL(vta_id)');
     }
     if (isset($options['where'])) {
         $qb->where($options['where']);
     }
     return $qb;
 }
예제 #4
0
 /**
  *
  * @param array $options
  * @return rad_query
  */
 private function _getListQuery($options, $fk = array())
 {
     $qb = new rad_query();
     if (isset($options['from'])) {
         $qb->from($options['from']);
     } else {
         $qb->from(RAD . 'cat_brands a');
     }
     if (isset($options['select'])) {
         $qb->select($options['select']);
     } else {
         if (count($fk)) {
             //if need to join some...
         } else {
             $qb->select('a.*');
         }
     }
     if (!empty($options['id']) and is_array($options['id'])) {
         $rcbId = '';
         //Do NOT use IMPLODE HERE!!! For safe method use foreach and (int)
         foreach ($options['id'] as $key => $value) {
             $rcbId .= (int) $value . ',';
         }
         $rcbId = substr($rcbId, 0, -1);
         $qb->where('a.rcb_id IN (' . $rcbId . ')');
     } elseif (isset($options['id']) || isset($options['rcb_id'])) {
         $tmp = (int) isset($options['id']) ? $options['id'] : $options['rcb_id'];
         $qb->where('a.rcb_id=:rcb_id')->value(array('rcb_id' => $tmp));
     }
     if (isset($options['order by'])) {
         $qb->order($options['order by']);
     } else {
         $qb->order('rcb_name ASC');
     }
     if (isset($options['active'])) {
         $qb->where('a.rcb_active=:active')->value(array('active' => (int) (bool) $options['active']));
     }
     if (isset($options['where'])) {
         $qb->where($options['where']);
     }
     //echo $qb->toString();
     return $qb;
 }
예제 #5
0
 /**
  * Gets the query
  *
  * @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['from'])) {
         $qb->from($fields['from']);
     } else {
         $qb->from(RAD . 'articles');
     }
     if (isset($fields['id'])) {
         $qb->where('art_id=:art_id')->value(array('art_id' => (int) $fields['id']));
     }
     if (isset($fields['isweek'])) {
         $qb->where('art_isweek=:art_isweek')->value(array('art_isweek' => $fields['isweek']));
     }
     if (isset($fields['order by'])) {
         $qb->order($fields['order by']);
     } else {
         $qb->order('art_position ASC,art_dateupdated DESC,art_title');
     }
     if (isset($fields['where'])) {
         $qb->where($fields['where']);
     }
     if (isset($fields['active'])) {
         $qb->where('art_active = :art_active')->value(array('art_active' => $fields['active']));
     }
     if (isset($fields['tre_id'])) {
         if (is_array($fields['tre_id'])) {
             $ids = '';
             foreach ($fields['tre_id'] as $id => $val) {
                 $ids .= (int) $val . ',';
             }
             $ids = substr($ids, 0, -1);
             $qb->where('art_treid IN (' . $ids . ')');
         } else {
             $qb->where('art_treid=:tre_id')->value(array('tre_id' => (int) $fields['tre_id']));
         }
     }
     if (isset($fields['lang']) or isset($fields['lang_id'])) {
         $langId = isset($fields['lang']) ? $fields['lang'] : $fields['lang_id'];
         $qb->where('art_langid=:lang_id')->value(array('lang_id' => (int) $langId));
     }
     return $qb;
 }
예제 #6
0
 /**
  * Get Activation URL record(s)
  * @return null|struct_coremail_subscribers_activationurl
  */
 function getActivationUrl()
 {
     $q = new rad_query();
     $q->from(RAD . 'subscribers_activationurl');
     $q->select('*');
     if ($this->getState('sac_type')) {
         $q->where('sac_type = :sac_type')->value(array('sac_type' => (int) $this->getState('sac_type')));
     }
     if ($this->getState('sac_url')) {
         $q->where('sac_url = :sac_url')->value(array('sac_url' => $this->getState('sac_url')));
     }
     if ($this->getState('sac_scrid')) {
         $q->where('sac_scrid = :sac_scrid')->value(array('sac_scrid' => $this->getState('sac_scrid')));
     }
     if ($res = $this->query($q->toString(), $q->getValues())) {
         $result = new struct_coremail_subscribers_activationurl($res);
         return $result;
     } else {
         return null;
     }
 }
예제 #7
0
 private function _getListQuery($fields)
 {
     $qb = new rad_query();
     if (isset($fields['select'])) {
         $qb->select($fields['select']);
     } else {
         $qb->select('*');
     }
     if (isset($fields['where'])) {
         $qb->where($fields['where']);
     }
     if (isset($fields['cur_id']) or isset($fields['id'])) {
         $val = isset($fields['cur_id']) ? $fields['cur_id'] : $fields['id'];
         $qb->where('cur_id="' . (int) $val . '"');
     }
     if (isset($fields['order by'])) {
         $qb->order($fields['order by']);
     }
     $qb->from(RAD . 'currency');
     return $qb;
 }
예제 #8
0
 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;
 }
예제 #9
0
 /**
  * Gets the partners statistics by period
  * @state date.from
  * @state date.ro
  * @return mixed array | NULL
  */
 function getRefStatistics($limit = null)
 {
     $limit = empty($limit) && $this->getState('limit') ? $this->getState('limit') : $limit;
     $limit = !empty($limit) ? ' LIMIT ' . $limit : '';
     if (!$this->getState('date.from')) {
         throw new rad_exception('Not enough actual param "date.from" in referals model!', __LINE__);
     }
     if (!$this->getState('date.to')) {
         throw new rad_exception('Not enough actual param "date.to" in referals model!', __LINE__);
     }
     /* calc ref count */
     $qRefCount = new rad_query();
     $qRefCount->select('count(t1.rrf_id)')->from(RAD . 'referals t1')->where('t1.rrf_user_id=a.u_id')->where('t1.rrf_date BETWEEN :date_from AND :date_to');
     /* calc orders count */
     $qOrderCount = new rad_query();
     $qOrderCount->select('count(*) AS ro_cnt')->from(RAD . 'referals_orders ro')->join('INNER', RAD . 'orders ON order_id=rro_order_id AND order_dt BETWEEN :date_from AND :date_to')->join('INNER', RAD . 'referals r ON rrf_id=rro_referals_id')->where('r.rrf_user_id=a.u_id');
     /* full query */
     $q = new rad_query();
     $q->from(RAD . 'users a');
     $q->select('a.*, (' . $qRefCount->toString() . ') refCount, (' . $qOrderCount->toString() . ') ordersCount')->value(array('date_from' => date($this->config('date.format'), $this->getState('date.from')), 'date_to' => date($this->config('date.format'), $this->getState('date.to') + 86400)))->where('a.u_email_confirmed=1')->having('refCount > 0 OR ordersCount > 0');
     if ($this->getState('search')) {
         $q->where('(u_login LIKE :search or u_email LIKE :search OR u_fio LIKE :search OR u_address LIKE :search OR u_phone LIKE :search)')->value(array('search' => '%' . $this->getState('search') . '%'));
     }
     $res = $this->queryAll($q->toString() . $limit, $q->getValues());
     //         die($q->toString().$limit.print_h($q->getValues(),true));
     if ($res) {
         $userIds = array();
         foreach ($res as &$id) {
             $userIds[] = $id['u_id'];
         }
         return $res;
     }
     return NULL;
 }
예제 #10
0
 /**
  * Gets the list query
  * @param array mixed $options
  * @param array mixed $fk
  * @return rad_query
  */
 private function _getListQuery($options, $fk = array())
 {
     $qb = new rad_query();
     if (isset($options['from'])) {
         $qb->from($options['from']);
     } else {
         $qb->from(RAD . 'users a');
     }
     if (isset($options['select'])) {
         $qb->select($options['select']);
     } else {
         if (count($fk)) {
             //if need to join some...
         } else {
             $qb->select('a.*');
         }
     }
     if (isset($options['id']) || isset($options['u_id'])) {
         $tmp = (int) isset($options['id']) ? $options['id'] : $options['u_id'];
         $qb->where('a.id=:a_id')->value(array('a_id' => $tmp));
     }
     if (isset($options['order by'])) {
         $qb->order($options['order by']);
     } else {
         $qb->order('u_active,u_email,u_login,u_group,u_access');
     }
     if (isset($options['u_group'])) {
         if (is_array($options['u_group'])) {
             foreach ($options['u_group'] as $key => $value) {
                 $grIds[(int) $key] = (int) $value;
             }
             $qb->where('u_group IN (' . implode(',', $grIds) . ')');
         } else {
             $qb->where('u_group=:u_group')->value(array('u_group' => (int) $options['u_group']));
         }
     }
     if (isset($options['u_active'])) {
         $qb->select('g.*');
         $qb->join('INNER', RAD . 'tree g ON g.tre_id=a.u_group');
     }
     if (isset($options['u_active'])) {
         $qb->where('u_active=:u_active')->value(array('u_active' => $options['u_active']));
     }
     if (isset($options['u_id'])) {
         $qb->where('u_id=:u_id')->value(array('u_id' => (int) $options['u_id']));
     }
     if (isset($options['u_login'])) {
         $qb->where('u_login=:u_login')->value(array('u_login' => $options['u_login']));
     }
     if (isset($options['u_pass'])) {
         $qb->where('u_pass=:u_pass')->value(array('u_pass' => $options['u_pass']));
     }
     if (isset($options['is_admin'])) {
         $qb->where('is_admin=:is_admin')->value(array('is_admin' => (int) $options['is_admin']));
     }
     if (isset($options['u_email'])) {
         $qb->where('u_email=:u_email')->value(array('u_email' => $options['u_email']));
     }
     if (isset($options['u_access'])) {
         $qb->where('u_access<:u_access')->value(array('u_access' => (int) $options['u_access']));
     }
     if (isset($options['u_email_confirmed'])) {
         $qb->where('u_email_confirmed=:u_confirmed')->value(array('u_confirmed' => $options['u_email_confirmed']));
     }
     if (isset($options['u_subscribe_active'])) {
         $qb->where('u_subscribe_active=:u_subscribe_active')->value(array('u_subscribe_active' => (int) $options['u_subscribe_active']));
     }
     if (isset($options['u_subscribe_langid'])) {
         $qb->where('u_subscribe_langid=:u_subscribe_langid')->value(array('u_subscribe_langid' => (int) $options['u_subscribe_langid']));
     }
     // SOCIAL SITE's USER ACCOUNT ID:
     if (isset($options['u_facebook_id'])) {
         $qb->where('u_facebook_id=:u_facebook_id')->value(array('u_facebook_id' => $options['u_facebook_id']));
     }
     if (isset($options['u_twitter_id'])) {
         $qb->where('u_twitter_id=:u_twitter_id')->value(array('u_twitter_id' => $options['u_twitter_id']));
     }
     // ---
     if (isset($options['where'])) {
         $qb->where($options['where']);
     }
     if (isset($options['code'])) {
         $qb->join('INNER', RAD . 'subscribers_activationurl ON sac_scrid=a.u_id AND sac_url=:sac_url AND sac_type=2 AND date_confirmed=0')->value(array('sac_url' => $options['code']));
     }
     return $qb;
 }
예제 #11
0
 /**
  * Gets the query
  *
  * @return rad_query
  */
 function _getListQuery($fk = array())
 {
     $qb = new rad_query();
     if ($this->getState('select')) {
         $qb->select($this->getState('select'));
     } else {
         $qb->select('*');
     }
     if ($this->getState('from')) {
         $qb->from($this->getState('from'));
     } else {
         $qb->from(RAD . 'pages');
     }
     if ($this->getState('id')) {
         $qb->where('pg_id=:pg_id')->value(array('pg_id' => (int) $this->getState('id')));
     }
     if ($this->getState('order by')) {
         $qb->order($this->getState('order by'));
     }
     if ($this->getState('where')) {
         $qb->where($this->getState('where'));
     }
     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;
             }
             $qb->where('pg_tre_id IN (' . implode(',', $treIds) . ')');
         } else {
             $qb->where('pg_tre_id=:pg_tre_id')->value(array('pg_tre_id' => (int) $this->getState('tre_id')));
         }
     }
     if ($this->issetState('active')) {
         $qb->where('pg_active=:pg_active')->value(array('pg_active' => (int) (bool) $this->getState('active')));
     }
     if ($this->getState('title')) {
         $qb->where('pg_title=:pg_title')->value(array('pg_title' => $this->getState('title')));
     }
     if ($this->getState('name')) {
         $qb->where('pg_name=:pg_name')->value(array('pg_name' => $this->getState('name')));
     }
     if ($this->getState('lang', $this->getState('lang_id'))) {
         $qb->where('pg_langid=:lang_id')->value(array('lang_id' => (int) $this->getState('lang', $this->getState('lang_id'))));
     }
     return $qb;
 }
예제 #12
0
 function getMinMaxPrices()
 {
     if (!$this->getStates('currency')) {
         throw new rad_exception('Not enouph actual parameters "currency" for getting minimal man maximum prices!');
     }
     $q = $this->_getListQuery();
     $qb = new rad_query();
     $qb->select('MIN(price) as minprice, MAX(price) AS maxprice')->from('(' . $q->toString() . ')tbl');
     return $this->query($qb->toString(), $q->getValues());
 }
예제 #13
0
 /**
  * for the searching aliases
  *
  * @param string $sw
  */
 function search($sw = '')
 {
     $q = new rad_query();
     $q->select('a.*,t.filename as filename');
     $q->from(RAD . 'aliases a');
     $q->join('LEFT', RAD . 'templates t on t.id = a.template_id');
     $q->where('a.ali_admin=' . (int) $this->getState('is_admin', 0), 'AND');
     $sql = $q->toString();
     $sql .= ' AND(alias like "%' . $sw . '%" OR filename like "%' . $sw . '%" OR description like "%' . $sw . '%")';
     //         $q->where('alias like "%'.$sw.'%"','OR');
     //         $q->where('filename like "%'.$sw.'%"','OR');
     //         $q->where('description like "%'.$sw.'%"','OR');
     $result = array();
     //die();
     //         foreach( $this->queryAll( $q->toString() ) as $key){
     foreach ($this->queryAll($sql) as $key) {
         $result[] = new struct_core_alias($key);
     }
     return $result;
 }
예제 #14
0
 /**
  * @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;
 }
예제 #15
0
 /**
  *
  * @param array $options
  * @return rad_query
  */
 private function _getListQuery($options, $fk = array())
 {
     $qb = new rad_query();
     if (isset($options['from'])) {
         $qb->from($options['from']);
     } else {
         $qb->from(RAD . 'news a');
     }
     if (isset($options['select'])) {
         $qb->select($options['select']);
     } else {
         if (count($fk)) {
             //if need to join some...
         } else {
             $qb->select('a.*');
         }
     }
     if (isset($options['id']) || isset($options['nw_id'])) {
         $tmp = (int) isset($options['id']) ? $options['id'] : $options['nw_id'];
         $qb->where('a.nw_id=:nw_id')->value(array('nw_id' => $tmp));
     }
     if (isset($options['order by'])) {
         $qb->order($options['order by']);
     } else {
         $qb->order('nw_datenews DESC,nw_dateupdated DESC,nw_title');
     }
     if (isset($options['lang'])) {
         $qb->where('nw_langid=:nw_langid')->value(array('nw_langid' => (int) $options['lang']));
     }
     if (isset($options['nw_datecreated'])) {
         $qb->where('nw_datecreated=:nw_datecreated')->value(array('nw_datecreated' => $options['nw_datecreated']));
     }
     if (isset($options['nw_dateupdated'])) {
         $qb->where('nw_dateupdated=:nw_dateupdated')->value(array('nw_dateupdated' => $options['nw_dateupdated']));
     }
     if (isset($options['nw_usercreated'])) {
         $qb->where('nw_usercreated=:nw_usercreated')->value(array('nw_usercreated' => (int) $options['nw_usercreated']));
     }
     if (isset($options['nw_tre_id']) or isset($options['pid']) or isset($options['tre_id'])) {
         $val = isset($options['pid']) ? $options['pid'] : isset($options['nw_tre_id']) ? $options['nw_tre_id'] : $options['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('nw_tre_id IN (' . $treeIds . ')');
         } else {
             $qb->where('nw_tre_id=:nw_tre_id')->value(array('nw_tre_id' => (int) $val));
         }
     }
     if (isset($options['nw_active'])) {
         $qb->where('nw_active=:nw_active')->value(array('nw_active' => (int) $options['nw_active']));
     }
     if (isset($options['nw_datenews'])) {
         $qb->where('nw_datenews=:nw_datenews')->value(array('nw_datenews' => $options['nw_datenews']));
     }
     if (isset($options['subscribe'])) {
         $qb->where('nw_subscribe=:nw_subscribe')->value(array('nw_subscribe' => (int) $options['subscribe']));
     }
     if (isset($options['userid'])) {
         $qb->where('nw_usercreated = :nw_usercreated')->value(array('nw_usercreated' => (int) $options['userid']));
     }
     if (isset($options['where'])) {
         $qb->where($options['where']);
     }
     //echo $qb->toString();
     return $qb;
 }
예제 #16
0
 /**
  * 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;
 }
예제 #17
0
 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;
 }
예제 #18
0
 function _getListQuery($options, $fk = array())
 {
     $qb = new rad_query();
     if (isset($options['from'])) {
         $qb->from($options['from']);
     } else {
         $qb->from(RAD . 'settings a');
     }
     if (isset($options['select'])) {
         $qb->select($options['select']);
     } else {
         if (count($fk)) {
             //if need to join some...
         } else {
             $qb->select('a.*');
         }
     }
     if (isset($options['id'])) {
         $qb->where('a.recordid=' . (int) $options['id']);
     }
     if (isset($options['order by'])) {
         $qb->order($options['order by']);
     } else {
         $qb->order('position,fldName');
     }
     if (isset($options['name'])) {
         $qb->where('a.fldName="' . $options['name'] . '"');
     }
     if (isset($options['name.like'])) {
         $qb->where('a.fldName LIKE "' . $options['name.like'] . '"');
     }
     return $qb;
 }
예제 #19
0
 /**
  * @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;
 }
예제 #20
0
 protected function getListQuery($fields)
 {
     $qb = new rad_query();
     if (isset($fields['select'])) {
         $qb->select(isset($fields['select']));
     } else {
         $qb->select('*');
     }
     if (isset($fields['pid'])) {
         $qb->where('tre_pid=:tre_pid')->value(array('tre_pid' => (int) $fields['pid']));
     }
     if (isset($fields['order'])) {
         $qb->order($fields['order']);
     } else {
         $qb->order('tre_position,tre_name');
     }
     if (isset($fields['access'])) {
         $qb->where('tre_access>=:tre_access')->value(array('tre_access' => (int) $fields['access']));
     }
     if (isset($fields['tre_id'])) {
         if (is_array($fields['tre_id']) and count($fields['tre_id'])) {
             $qb->where('tre_id in (' . implode(',', $fields['tre_id']) . ')');
         } else {
             $qb->where('tre_id=:tre_id')->value(array('tre_id' => (int) $fields['tre_id']));
         }
     }
     if (isset($fields['tre_active']) or isset($fields['active'])) {
         $active = isset($fields['tre_active']) ? $fields['tre_active'] : $fields['active'];
         $qb->where('tre_active=:tre_active')->value(array('tre_active' => $active));
     }
     if (isset($fields['lang']) or isset($fields['lngid']) or isset($fields['lang_id']) or isset($fields['tre_lang'])) {
         $lngid = isset($fields['lang']) ? $fields['lang'] : (isset($fields['lngid']) ? $fields['lngid'] : (isset($fields['lang_id']) ? $fields['lang_id'] : (isset($fields['tre_lang']) ? $fields['tre_lang'] : 0)));
         if ((int) $lngid) {
             $qb->where('tre_lang=:tre_lang')->value(array('tre_lang' => $lngid));
         } else {
             throw new rad_exception('Unknown type of lng_id', __LINE__);
         }
     }
     $qb->from(RAD . 'tree');
     return $qb;
 }