예제 #1
0
 /**
  * this function shows us our all lots
  * 
  */
 public function actionMyLots()
 {
     if ($this->request->order == "") {
         $products = MyProduct::getMyProduct($this->user->id);
         if (!$products) {
             $products = [];
         }
         $countLots = $this->user->getQuantityLots();
         $countBids = $this->user->getQuantityBids();
         if ($countLots == "") {
             $countLots = 0;
         }
         if ($countBids == "") {
             $countBids = 0;
         }
         $this->view->lots = $countLots;
         $this->view->countBids = $countBids;
         $this->view->user = $this->name;
         $this->view->products = $products;
         $this->view->render('mylots');
         $this->view->display();
     } else {
         $id = (int) $_POST["order"];
         $fields = ["title", "description", "current_price", "id", "front_img", "created"];
         $where = "user_id = ? ";
         $user_id = $this->user->id;
         $select = new SelectPDO();
         $select->from("lot", $fields)->where($where, array($user_id));
         switch ($id) {
             case '0':
                 $select->order("current_price", false);
                 break;
             case '1':
                 $select->order("current_price", true);
                 break;
             case '2':
                 $select->order("created");
                 break;
             default:
                 $select->order("title");
                 break;
         }
         $data = AbstractModel::getOnComplexQuery($select);
         $data = json_encode($data);
         echo $data;
         exit;
         $products = MyProduct::getMyProduct($this->user->id);
         echo json_encode($products);
     }
 }
예제 #2
0
 /**
  * get all data from table by where, order and limit
  * 
  * @param $table
  * @param bool|false $where
  * @param $params
  * @param bool|false $order
  * @param bool|false $desc
  * @param bool|false $limit
  * @param string $offset
  * @return array|bool
  */
 public static function getWithAllParams($table, $fields = false, $where = false, $params, $order = false, $desc = false, $limit = false, $offset = false)
 {
     $select = new SelectPDO();
     if ($fields) {
         $select->from($table, $fields);
     } else {
         $select->from($table, "*");
     }
     if ($where) {
         $select->where($where, $params);
     }
     if ($order) {
         $select->order($order, $desc);
     }
     if ($limit) {
         $select->limit($limit, $offset);
     }
     //  exit($select->query());
     $data = self::$db->select($select);
     if ($data) {
         return $data;
     } else {
         return false;
     }
 }