Exemplo n.º 1
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;
 }
Exemplo n.º 2
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;
     }
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
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());
 }