public function featured_products()
 {
     $products = array();
     if ($pros = Product::query()->where([['`active`', '=', 1]])->order_by('`view`')->take(10)->get()) {
         while ($row = $pros->fetch_assoc()) {
             $pro = new Product($row);
             if ($imgs = Data_Provider::execute_query('select * from eli_product_image where `id_product`=' . $pro->id . ' limit 1')) {
                 $images = array();
                 if ($other_row = $imgs->fetch_assoc()) {
                     $image = new Product_Image($other_row);
                     array_push($images, $image);
                 }
                 $pro->images = $images;
                 $imgs->free();
             }
             array_push($products, $pro);
         }
         $pros->free();
     }
     $this->render('views/_shared/_featured_product.php', ['products' => $products]);
 }
Example #2
0
 public function get()
 {
     $rs = Data_Provider::execute_query(self::$query);
     return $rs;
 }