当前位置: 首页>>代码示例>>PHP>>正文


PHP Date::unix2mysql方法代码示例

本文整理汇总了PHP中Date::unix2mysql方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::unix2mysql方法的具体用法?PHP Date::unix2mysql怎么用?PHP Date::unix2mysql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Date的用法示例。


在下文中一共展示了Date::unix2mysql方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renew

 /**
  * expired featured ads
  * @return void
  */
 public static function renew()
 {
     if (Core::config('general.subscriptions') == TRUE) {
         //get expired subscription that are active
         $subscriptions = new Model_Subscription();
         $subscriptions = $subscriptions->where('status', '=', 1)->where('expire_date', '<=', Date::unix2mysql())->order_by('created', 'desc')->find_all();
         foreach ($subscriptions as $s) {
             //disable the plan
             $s->status = 0;
             try {
                 $s->save();
             } catch (Exception $e) {
                 throw HTTP_Exception::factory(500, $e->getMessage());
             }
             $plan = $s->plan;
             if ($plan->loaded() and $plan->status == 1) {
                 //generate a new order
                 $order = Model_Order::new_order(NULL, $s->user, $plan->id_plan, $plan->price, core::config('payment.paypal_currency'), __('Subscription to ') . $plan->name);
                 //free plan no checkout
                 if ($plan->price == 0) {
                     $order->confirm_payment('cash');
                 } else {
                     $checkout_url = $s->user->ql('default', array('controller' => 'plan', 'action' => 'checkout', 'id' => $order->id_order));
                     $s->user->email('plan-expired', array('[PLAN.NAME]' => $plan->name, '[URL.CHECKOUT]' => $checkout_url));
                 }
             }
             //if plan loaded
         }
         //end foreach
     }
     //if subscription active
 }
开发者ID:ThomWensink,项目名称:openclassifieds2,代码行数:36,代码来源:subscription.php

示例2: before

 /**
  * Automatically executed before the widget action. Can be used to set
  * class properties, do authorization checks, and execute other custom code.
  *
  * @return  void
  */
 public function before()
 {
     $ads = new Model_Ad();
     $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
     //if ad have passed expiration time dont show
     if (core::config('advertisement.expire_date') > 0) {
         $ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', Date::unix2mysql());
     }
     switch ($this->ads_type) {
         case 'popular':
             $id_ads = array_keys(Model_Visit::popular_ads());
             if (count($id_ads) > 0) {
                 $ads->where('id_ad', 'IN', $id_ads);
             }
             break;
         case 'featured':
             $ads->where('featured', 'IS NOT', NULL)->where('featured', '>', Date::unix2mysql())->order_by('featured', 'desc');
             break;
         case 'latest':
         default:
             $ads->order_by('published', 'desc');
             break;
     }
     $ads = $ads->limit($this->ads_limit)->cached()->find_all();
     //die(print_r($ads));
     $this->ads = $ads;
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:33,代码来源:ads.php

示例3: action_index

 public function action_index()
 {
     //template header
     $this->template->title = '';
     // $this->template->meta_keywords    = 'keywords';
     $this->template->meta_description = Core::config('general.site_description');
     //setting main view/template and render pages
     // swith to decide on ads_in_home
     $ads = new Model_Ad();
     $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
     switch (core::config('advertisement.ads_in_home')) {
         case 2:
             $id_ads = array_keys(Model_Visit::popular_ads());
             if (count($id_ads) > 0) {
                 $ads->where('id_ad', 'IN', $id_ads);
             }
             break;
         case 1:
             $ads->where('featured', 'IS NOT', NULL)->where('featured', 'BETWEEN', array(DB::expr('NOW()'), Date::unix2mysql(time() + core::config('payment.featured_days') * 24 * 60 * 60)))->order_by('featured', 'desc');
             break;
         case 0:
         default:
             $ads->order_by('published', 'desc');
             break;
     }
     //if ad have passed expiration time dont show
     if (core::config('advertisement.expire_date') > 0) {
         $ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', DB::expr('NOW()'));
     }
     $ads = $ads->limit(Theme::get('num_home_latest_ads', 4))->cached()->find_all();
     $this->ads = $ads;
     $categs = Model_Category::get_category_count();
     $this->template->bind('content', $content);
     $this->template->content = View::factory('pages/home', array('ads' => $ads, 'categs' => $categs));
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:35,代码来源:home.php

示例4: before

 /**
  * Automatically executed before the widget action. Can be used to set
  * class properties, do authorization checks, and execute other custom code.
  *
  * @return  void
  */
 public function before()
 {
     $ads = new Model_Ad();
     $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
     $ads->where('featured', 'IS NOT', NULL)->where('featured', '>', Date::unix2mysql())->order_by('featured', 'desc');
     $ads = $ads->limit($this->ads_limit)->find_all();
     $this->ads = $ads;
 }
开发者ID:zhangkom,项目名称:openclassifieds2,代码行数:14,代码来源:featured.php

示例5: before

 /**
  * Automatically executed before the widget action. Can be used to set
  * class properties, do authorization checks, and execute other custom code.
  *
  * @return  void
  */
 public function before()
 {
     $ads = new Model_Ad();
     $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
     $ads->where('featured', 'IS NOT', NULL)->where('featured', 'BETWEEN', array(DB::expr('NOW()'), Date::unix2mysql(time() + core::config('payment.featured_days') * 24 * 60 * 60)))->order_by('featured', 'desc');
     $ads = $ads->limit($this->ads_limit)->cached()->find_all();
     $this->ads = $ads;
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:14,代码来源:featured.php

示例6: action_index

 public function action_index()
 {
     if (core::config('general.auto_locate')) {
         Theme::$scripts['footer'][] = '//maps.google.com/maps/api/js?sensor=false&libraries=geometry&v=3.7';
         Theme::$scripts['footer'][] = '//cdn.jsdelivr.net/gmaps/0.4.15/gmaps.min.js';
     }
     //template header
     $this->template->title = '';
     // $this->template->meta_keywords    = 'keywords';
     if (core::config('general.site_description') != '') {
         $this->template->meta_description = core::config('general.site_description');
     } else {
         $this->template->meta_description = core::config('general.site_name') . ' ' . __('official homepage, get your post listed now.');
     }
     //setting main view/template and render pages
     // swith to decide on ads_in_home
     $ads = new Model_Ad();
     $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
     $ads_in_home = core::config('advertisement.ads_in_home');
     //in case we do not count visits we cant show popular
     if (core::config('advertisement.count_visits') == 0 and $ads_in_home == 2) {
         $ads_in_home = 0;
     }
     switch ($ads_in_home) {
         case 2:
             $id_ads = array_keys(Model_Visit::popular_ads());
             if (count($id_ads) > 0) {
                 $ads->where('id_ad', 'IN', $id_ads);
             }
             break;
         case 1:
             $ads->where('featured', 'IS NOT', NULL)->where('featured', '>=', Date::unix2mysql())->order_by('featured', 'desc');
             break;
         case 4:
             $ads->where('featured', 'IS NOT', NULL)->where('featured', '>=', Date::unix2mysql())->order_by(DB::expr('RAND()'));
             break;
         case 0:
         default:
             $ads->order_by('published', 'desc');
             break;
     }
     //if ad have passed expiration time dont show
     if (core::config('advertisement.expire_date') > 0) {
         $ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', Date::unix2mysql());
     }
     $ads = $ads->limit(Theme::get('num_home_latest_ads', 4))->cached()->find_all();
     $categs = Model_Category::get_category_count();
     $locats = Model_Location::get_location_count();
     $auto_locats = NULL;
     if (core::config('general.auto_locate') and Model_User::get_userlatlng()) {
         $auto_locats = new Model_Location();
         $auto_locats = $auto_locats->select(array(DB::expr('degrees(acos(sin(radians(' . $_COOKIE['mylat'] . ')) * sin(radians(`latitude`)) + cos(radians(' . $_COOKIE['mylat'] . ')) * cos(radians(`latitude`)) * cos(radians(abs(' . $_COOKIE['mylng'] . ' - `longitude`))))) * 111.321'), 'distance'))->where('latitude', 'IS NOT', NULL)->where('longitude', 'IS NOT', NULL)->having('distance', '<=', '100')->order_by('distance', 'desc')->find_all()->as_array();
     }
     $this->template->bind('content', $content);
     $this->template->content = View::factory('pages/home', array('ads' => $ads, 'categs' => $categs, 'locats' => $locats, 'auto_locats' => $auto_locats));
 }
开发者ID:nick-catanchin-ie,项目名称:openclassifieds2,代码行数:56,代码来源:home.php

示例7: create

 /**
  * Insert a new object to the database - Overwrite!
  * @param  Validation $validation Validation object
  * @throws Kohana_Exception
  * @return ORM
  */
 public function create(Validation $validation = NULL)
 {
     //Hack to use the PHP date time instead of the MySQL for created
     $cols = $this->list_columns();
     // the column created exists and we didnt pass any value before
     if (isset($cols['created']) and !array_key_exists('created', $this->_changed)) {
         //add the value, forcing it so wont use the DB default ;)
         $this->set('created', Date::unix2mysql());
     }
     return parent::create($validation);
 }
开发者ID:JeffPedro,项目名称:project-garage-sale,代码行数:17,代码来源:orm.php

示例8: action_index

 public function action_index()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Newsletter')));
     $this->template->title = __('Newsletter');
     //count all users
     $user = new Model_User();
     $user->where('status', '=', Model_User::STATUS_ACTIVE);
     $count_all_users = $user->count_all();
     //count support expired
     $query = DB::select(DB::expr('COUNT(id_order) count'))->from('orders')->where('status', '=', Model_Order::STATUS_PAID)->where('support_date', '<', Date::unix2mysql())->execute();
     $count_support_expired = $query->as_array();
     $count_support_expired = $count_support_expired[0]['count'];
     //count license expired
     $query = DB::select(DB::expr('COUNT(id_license) count'))->from('licenses')->where('valid_date', 'IS NOT', NULL)->where('valid_date', '<', Date::unix2mysql())->execute();
     $count_license_expired = $query->as_array();
     $count_license_expired = $count_license_expired[0]['count'];
     //orders per product, not accuarate since 1 user could buy more than 1 product but will do
     $query = DB::select(DB::expr('COUNT(id_order) count'))->select('p.title')->select('p.id_product')->from(array('products', 'p'))->join(array('orders', 'o'))->using('id_product')->where('o.status', '=', Model_Order::STATUS_PAID)->group_by('p.id_product')->execute();
     $products = $query->as_array();
     //post done sending newsletter
     if ($this->request->post() and Core::post('subject') != NULL) {
         $users = array();
         if (core::post('send_all') == 'on') {
             $query = DB::select('email')->select('name')->from('users')->where('status', '=', Model_User::STATUS_ACTIVE)->execute();
             $users = array_merge($users, $query->as_array());
         }
         if (Theme::get('premium') == 1) {
             if (core::post('send_expired_support') == 'on') {
                 $query = DB::select('email')->select('name')->from(array('users', 'u'))->join(array('orders', 'o'))->using('id_user')->where('o.status', '=', Model_Order::STATUS_PAID)->where('o.support_date', '<', Date::unix2mysql())->where('u.subscriber', '=', 1)->group_by('u.id_user')->execute();
                 $users = array_merge($users, $query->as_array());
             }
             if (core::post('send_expired_license') == 'on') {
                 $query = DB::select('email')->select('name')->from(array('licenses', 'l'))->join(array('users', 'u'))->using('id_user')->where('l.valid_date', 'IS NOT', NULL)->where('l.valid_date', '<', Date::unix2mysql())->where('u.subscriber', '=', 1)->group_by('u.id_user')->execute();
                 $users = array_merge($users, $query->as_array());
             }
             if (is_numeric(core::post('send_product'))) {
                 $query = DB::select('email')->select('name')->from(array('users', 'u'))->join(array('orders', 'o'))->using('id_user')->where('o.id_product', '=', core::post('send_product'))->where('o.status', '=', Model_Order::STATUS_PAID)->where('u.subscriber', '=', 1)->group_by('u.id_user')->execute();
                 $users = array_merge($users, $query->as_array());
             }
         }
         //NOTE $users may have duplicated emails, but phpmailer takes care of not sending the email 2 times to same recipient
         //sending!
         if (count($users) > 0) {
             if (!Email::send($users, '', Core::post('subject'), Kohana::$_POST_ORIG['description'], Core::post('from'), Core::post('from_email'))) {
                 Alert::set(Alert::ERROR, __('Error on mail delivery, not sent'));
             } else {
                 Alert::set(Alert::SUCCESS, __('Email sent'));
             }
         } else {
             Alert::set(Alert::ERROR, __('Mail not sent'));
         }
     }
     $this->template->content = View::factory('oc-panel/pages/newsletter', array('count_all_users' => $count_all_users, 'count_support_expired' => $count_support_expired, 'count_license_expired' => $count_license_expired, 'products' => $products));
 }
开发者ID:Ryanker,项目名称:open-eshop,代码行数:54,代码来源:newsletter.php

示例9: renew

 /**
  * expired featured ads
  * @return void
  */
 public static function renew()
 {
     if (Core::config('general.subscriptions') == TRUE) {
         //get expired subscription that are active
         $subscriptions = new Model_Subscription();
         $subscriptions = $subscriptions->where('status', '=', 1)->where('expire_date', '<=', Date::unix2mysql())->order_by('created', 'desc')->find_all();
         foreach ($subscriptions as $s) {
             //disable the plan
             $s->status = 0;
             try {
                 $s->save();
             } catch (Exception $e) {
                 throw HTTP_Exception::factory(500, $e->getMessage());
             }
             $plan = $s->plan;
             if ($plan->loaded() and $plan->status == 1) {
                 //generate a new order
                 $order = Model_Order::new_order(NULL, $s->user, $plan->id_plan, $plan->price, core::config('payment.paypal_currency'), __('Subscription to ') . $plan->name);
                 //free plan no checkout
                 if ($plan->price == 0) {
                     $order->confirm_payment('cash');
                 } else {
                     $paid = FALSE;
                     //customers who paid with sripe we can charge the recurrency
                     if ($order->user->stripe_agreement != NULL) {
                         StripeKO::init();
                         // Create the charge on Stripe's servers - this will charge the user's card
                         try {
                             $charge = \Stripe\Charge::create(array("amount" => StripeKO::money_format($order->amount), "currency" => $order->currency, 'customer' => $order->user->stripe_agreement, "description" => $order->description, "metadata" => array("id_order" => $order->id_order)));
                             $paid = TRUE;
                         } catch (Exception $e) {
                             // The card has been declined
                             Kohana::$log->add(Log::ERROR, 'Stripe The card has been declined');
                             $paid = FALSE;
                         }
                     }
                     if ($paid === TRUE) {
                         //mark as paid
                         $order->confirm_payment('stripe', $charge->id);
                     } else {
                         $checkout_url = $s->user->ql('default', array('controller' => 'plan', 'action' => 'checkout', 'id' => $order->id_order));
                         $s->user->email('plan-expired', array('[PLAN.NAME]' => $plan->name, '[URL.CHECKOUT]' => $checkout_url));
                     }
                 }
             }
             //if plan loaded
         }
         //end foreach
     }
     //if subscription active
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:55,代码来源:subscription.php

示例10: expired_featured

 /**
  * expired featured ads
  * @return void
  */
 public static function expired_featured()
 {
     //find expired ads of yesterday
     $ads = new Model_Ad();
     $ads = $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where('featured', '<', Date::unix2mysql())->where('featured', 'IS NOT', NULL)->find_all();
     foreach ($ads as $ad) {
         $edit_url = $ad->user->ql('oc-panel', array('controller' => 'myads', 'action' => 'update', 'id' => $ad->id_ad));
         $ad->user->email('ad-expired', array('[AD.NAME]' => $ad->title, '[URL.EDITAD]' => $edit_url));
         //unset featured ad
         $ad->featured = NULL;
         try {
             $ad->save();
         } catch (Exception $e) {
             throw HTTP_Exception::factory(500, $e->getMessage());
         }
     }
 }
开发者ID:Chinese1904,项目名称:openclassifieds2,代码行数:21,代码来源:ad.php

示例11: action_pay

 /**
  *
  * view affiliates and payments
  */
 public function action_pay()
 {
     //create an order and mark it as paid to the user_id
     if (is_numeric($this->request->param('id'))) {
         //get the user
         $user = new Model_User($this->request->param('id'));
         if ($user->loaded()) {
             //commissions due to pay
             $query = DB::select(DB::expr('SUM(amount) total'))->from('affiliates')->where('id_user', '=', $user->id_user)->where('date_to_pay', '<', Date::unix2mysql())->where('status', '=', Model_Affiliate::STATUS_CREATED)->group_by('id_user')->execute();
             $due_to_pay = $query->as_array();
             $due_to_pay = isset($due_to_pay[0]['total']) ? $due_to_pay[0]['total'] : 0;
             if ($due_to_pay > 0) {
                 //create the order
                 $order = new Model_Order();
                 $order->id_user = $user->id_user;
                 $order->amount = $due_to_pay * -1;
                 //we add the order as a negative, since we pay, we don't get paid.
                 $order->currency = 'USD';
                 $order->paymethod = 'paypal';
                 $order->pay_date = Date::unix2mysql();
                 $order->notes = 'Affiliate Commissions';
                 $order->status = Model_Order::STATUS_PAID;
                 try {
                     $order->save();
                     //update the commissions
                     DB::update('affiliates')->set(array('date_paid' => Date::unix2mysql(), 'status' => Model_Affiliate::STATUS_PAID, 'id_order_payment' => $order->id_order))->where('id_user', '=', $user->id_user)->where('date_to_pay', '<', Date::unix2mysql())->where('status', '=', Model_Affiliate::STATUS_CREATED)->execute();
                     Alert::set(Alert::SUCCESS, __('Commission Paid'));
                 } catch (Exception $e) {
                 }
             }
         }
     }
     $this->template->title = __('Affiliates Payments');
     $query = DB::select(DB::expr('SUM(amount) total'))->select('id_user')->from('affiliates')->where('date_to_pay', '<', Date::unix2mysql())->where('status', '=', Model_Affiliate::STATUS_CREATED)->group_by('id_user')->having('total', '>=', core::config('affiliate.payment_min'))->execute();
     $users_to_pay = $query->as_array('id_user');
     $total_to_pay = 0;
     foreach ($users_to_pay as $key => $value) {
         $total_to_pay += $value['total'];
     }
     $users = new Model_User();
     if (count($users_to_pay)) {
         $users = $users->where('id_user', 'in', array_keys($users_to_pay))->where('status', '=', Model_User::STATUS_ACTIVE)->find_all();
     }
     $this->render('oc-panel/pages/affiliate/pay', array('users' => $users, 'total_to_pay' => $total_to_pay, 'users_to_pay' => $users_to_pay));
 }
开发者ID:Ryanker,项目名称:open-eshop,代码行数:49,代码来源:affiliate.php

示例12: action_index

 public function action_index()
 {
     $this->before('/pages/maps');
     $this->template->title = __('Map');
     $this->template->height = Core::get('height', '100%');
     $this->template->width = Core::get('width', '100%');
     $this->template->zoom = Core::get('zoom', core::config('advertisement.map_zoom'));
     $this->template->height_thumb = Core::config('image.height_thumb') / 4;
     $this->template->width_thumb = Core::config('image.width_thumb') / 4;
     if (Model_User::get_userlatlng()) {
         $this->template->center_lon = $_COOKIE['mylng'];
         $this->template->center_lat = $_COOKIE['mylat'];
     } else {
         $this->template->center_lon = Core::get('lon', core::config('advertisement.center_lon'));
         $this->template->center_lat = Core::get('lat', core::config('advertisement.center_lat'));
     }
     $ads = new Model_Ad();
     $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where('address', 'IS NOT', NULL)->where('latitude', 'IS NOT', NULL)->where('longitude', 'IS NOT', NULL);
     //filter by category
     if (core::get('category') !== NULL) {
         $category = new Model_Category();
         $category->where('seoname', '=', core::get('category'))->cached()->limit(1)->find();
         if ($category->loaded()) {
             $ads->where('id_category', 'IN', $category->get_siblings_ids());
         }
     }
     //filter by location
     if (core::get('location') !== NULL) {
         $location = new Model_location();
         $location->where('seoname', '=', core::get('location'))->cached()->limit(1)->find();
         if ($location->loaded()) {
             $ads->where('id_location', 'IN', $location->get_siblings_ids());
         }
     }
     //if ad have passed expiration time dont show
     if (core::config('advertisement.expire_date') > 0) {
         $ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', Date::unix2mysql());
     }
     //if only 1 ad
     if (is_numeric(core::get('id_ad'))) {
         $ads = $ads->where('id_ad', '=', core::get('id_ad'));
     }
     $ads = $ads->order_by('published', 'desc')->limit(Core::config('advertisement.map_elements'))->find_all();
     $this->template->ads = $ads;
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:45,代码来源:map.php

示例13: action_get

 /**
  * Handle GET requests.
  */
 public function action_get()
 {
     try {
         if (($coupon_name = $this->request->param('id')) != NULL) {
             $coupon = new Model_Coupon();
             $coupon->where('name', '=', $coupon_name)->where('number_coupons', '>', 0)->where('valid_date', '>', Date::unix2mysql())->where('status', '=', 1);
             //filter by product
             if (is_numeric(core::request('id_product'))) {
                 $coupon->where('id_product', '=', core::request('id_product'));
             }
             $coupon = $coupon->limit(1)->find();
             $this->rest_output(array('coupon' => $coupon->loaded() ? $coupon->as_array() : FALSE));
         } else {
             $this->_error('You need to specify a coupon');
         }
     } catch (Kohana_HTTP_Exception $khe) {
         $this->_error($khe);
     }
 }
开发者ID:Ryanker,项目名称:open-eshop,代码行数:22,代码来源:coupon.php

示例14: new_order

 /**
  * new order therefore new subscription created
  * @param  Model_Order $order 
  * @return void             
  */
 public static function new_order(Model_Order $order)
 {
     $plan = new Model_Plan($order->id_product);
     //disable all the previous membership
     DB::update('subscriptions')->set(array('status' => 0))->where('id_user', '=', $order->id_user)->execute();
     //create a new subscription for this product
     $subscription = new Model_Subscription();
     $subscription->id_order = $order->id_order;
     $subscription->id_user = $order->id_user;
     $subscription->id_plan = $plan->id_plan;
     $subscription->amount_ads = $plan->amount_ads;
     $subscription->amount_ads_left = $plan->amount_ads;
     $subscription->expire_date = Date::unix2mysql(strtotime('+' . $plan->days . ' days'));
     $subscription->status = 1;
     try {
         $subscription->save();
     } catch (Exception $e) {
         throw HTTP_Exception::factory(500, $e->getMessage());
     }
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:25,代码来源:subscription.php

示例15: action_index

 public function action_index()
 {
     //template header
     $this->template->title = '';
     // $this->template->meta_keywords    = 'keywords';
     $this->template->meta_description = Core::config('general.site_name') . ' ' . __('official homepage for the online store');
     $products = new Model_Product();
     $products->where('status', '=', Model_Product::STATUS_ACTIVE);
     switch (core::config('product.products_in_home')) {
         case 3:
             $id_products = Model_Review::best_rated();
             $array_ids = array();
             foreach ($id_products as $id => $id_product) {
                 $array_ids = $id_product;
             }
             if (count($id_products) > 0) {
                 $products->where('id_product', 'IN', $array_ids);
             }
             break;
         case 2:
             $id_products = array_keys(Model_Visit::popular_products());
             if (count($id_products) > 0) {
                 $products->where('id_product', 'IN', $id_products);
             }
             break;
         case 1:
             $products->where('featured', 'IS NOT', NULL)->where('featured', '>', Date::unix2mysql())->order_by('featured', 'desc');
             break;
         case 0:
         default:
             $products->order_by('created', 'desc');
             break;
     }
     $products = $products->limit(Theme::get('num_home_products', 21))->cached()->find_all();
     $categs = Model_Category::get_category_count();
     $this->template->bind('content', $content);
     $this->template->content = View::factory('pages/home', array('products' => $products, 'categs' => $categs));
 }
开发者ID:Ryanker,项目名称:open-eshop,代码行数:38,代码来源:home.php


注:本文中的Date::unix2mysql方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。