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


PHP Collection::where方法代码示例

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


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

示例1: getValidatedByIdTab

 public static function getValidatedByIdTab($id_tab)
 {
     $advices = new Collection('advice', Context::getContext()->language->id);
     $advices->where('validated', '=', 1);
     $advices->where('id_tab', '=', (int) $id_tab);
     return $advices;
 }
开发者ID:rongandat,项目名称:vatfairfoot,代码行数:7,代码来源:Advice.php

示例2: getShopGroups

 public static function getShopGroups($active = true)
 {
     $groups = new Collection('ShopGroup');
     $groups->where('deleted', '=', false);
     if ($active) {
         $groups->where('active', '=', true);
     }
     return $groups;
 }
开发者ID:toufikadfab,项目名称:PrestaShop-1.5,代码行数:9,代码来源:ShopGroup.php

示例3: renderView

    public function renderView()
    {
        $badges_feature = new Collection('badge', $this->context->language->id);
        $badges_feature->where('type', '=', 'feature');
        $badges_feature->orderBy('id_group');
        $badges_feature->orderBy('group_position');
        $badges_achievement = new Collection('badge', $this->context->language->id);
        $badges_achievement->where('type', '=', 'achievement');
        $badges_achievement->orderBy('id_group');
        $badges_achievement->orderBy('group_position');
        $badges_international = new Collection('badge', $this->context->language->id);
        $badges_international->where('type', '=', 'international');
        $badges_international->orderBy('id_group');
        $badges_international->orderBy('group_position');
        $groups = array();
        $query = new DbQuery();
        $query->select('DISTINCT(b.`id_group`), bl.group_name, b.type');
        $query->from('badge', 'b');
        $query->join('
			LEFT JOIN `' . _DB_PREFIX_ . 'badge_lang` bl ON bl.`id_badge` = b.`id_badge`');
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
        foreach ($result as $res) {
            $groups['badges_' . $res['type']][$res['id_group']] = $res['group_name'];
        }
        $badges_type = array('badges_feature' => array('name' => $this->l('Features'), 'badges' => $badges_feature), 'badges_achievement' => array('name' => $this->l('Achievements'), 'badges' => $badges_achievement), 'badges_international' => array('name' => $this->l('International'), 'badges' => $badges_international));
        $levels = array(1 => $this->l('1. Beginner'), 2 => $this->l('2. Pro'), 3 => $this->l('3. Expert'), 4 => $this->l('4. Wizard'), 5 => $this->l('5. Guru'), 6 => $this->l('6. Legend'));
        $this->tpl_view_vars = array('badges_type' => $badges_type, 'current_level_percent' => (int) Configuration::get('GF_CURRENT_LEVEL_PERCENT'), 'current_level' => (int) Configuration::get('GF_CURRENT_LEVEL'), 'groups' => $groups, 'levels' => $levels);
        return parent::renderView();
    }
开发者ID:rongandat,项目名称:vatfairfoot,代码行数:29,代码来源:AdminGamificationController.php

示例4: getShopUrls

 /**
  * Get list of shop urls
  *
  * @param bool $id_shop
  * @return Collection
  */
 public static function getShopUrls($id_shop = false)
 {
     $urls = new Collection('ShopUrl');
     if ($id_shop) {
         $urls->where('id_shop', '=', $id_shop);
     }
     return $urls;
 }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:14,代码来源:ShopUrl.php

示例5: getUserLastCollectionUsed

 private function getUserLastCollectionUsed()
 {
     $user_id = Auth::user()->id;
     $coll_id = Collection::where('user_id', $user_id)->where("last_used", 1)->pluck('id');
     // dd($coll_id);
     if ($coll_id) {
         return $coll_id;
     } else {
         return null;
     }
 }
开发者ID:ke6scs,项目名称:samples,代码行数:11,代码来源:TitleController.php

示例6: actionDefault

 protected static function actionDefault()
 {
     $products = new Collection('Product', App::currentLang()->getId());
     $products->link('cover');
     $products->where("`id` IN (" . implode(',', array_keys($_SESSION['cart'])) . ")");
     $products = $products->items();
     foreach ($products as $product) {
         $product->quantity = $_SESSION['cart'][$product->getId()];
     }
     self::templateVar('cart_items', $products);
     return self::displayPage('cart');
 }
开发者ID:swash13,项目名称:shop,代码行数:12,代码来源:Cart.php

示例7: submit_products

function submit_products()
{
    $start = 0;
    while (true) {
        $inventories = Inventory::whereNull('shopify_id')->orWhere('dirty', 1)->skip($start)->take(100)->get();
        $cnt = count($inventories);
        if ($cnt == 0) {
            break;
        }
        foreach ($inventories as $inventory) {
            if ($inventory->image == '') {
                continue;
            }
            if ($inventory->shopify_id == NULL) {
                $amzInfo = AmazonInfo::where("inventory_id", $inventory->id)->first();
                $collection = Collection::where("name", $amzInfo->category1)->first();
                if ($collection == NULL) {
                    //echo '[', date('Y-m-d H:m:s'), '] Skip - ', $inventory->name, "\r\n";
                    continue;
                }
                $result = create_product($inventory->name, $inventory->description, 'Bellwether', 'Book', $inventory->sku, $inventory->price, $inventory->quantity, $inventory->image, $inventory->isbn);
                if ($result['success'] == 'true') {
                    /*
                    	Check if collection exists and add product & category...
                    */
                    if ($collection != NULL) {
                        $inventory->dirty = 0;
                        $sid = $result['product']['id'];
                        $inventory->shopify_id = $sid;
                        $inventory->save();
                        echo '[', date('Y-m-d H:m:s'), '] Added Product - ', "ID ", $sid, ", ", $inventory->name, "\r\n";
                        add_product_to_collection($result['product']['id'], $collection->shopify_id);
                        echo 'Added to Collection - ' . $collection->name . "\r\n";
                    }
                }
            } else {
                $result = update_product_content($inventory->shopify_id, $inventory->price, $inventory->quantity, $inventory->sku);
                if ($result['success'] == 'true') {
                    $inventory->dirty = 0;
                    $inventory->save();
                    echo 'Updated Product - ' . $inventory->name . "\r\n";
                }
            }
        }
        $start += $cnt;
    }
}
开发者ID:Alex--Jin,项目名称:shopify_private_fillz,代码行数:47,代码来源:quick_push_products.php

示例8: actionDefault

 protected static function actionDefault()
 {
     /*
      * Если выводиться вся страница то списко товаров передается шаблону products-list таким образом
      * Controller -> index -> products-list
      * Если запрос аяксовый то переменные передаются напрямую шаблону products-list
      * Controller -> products-list
      * Но при создании этих переменных мы не думаем о том какой шаблон будет выводиться.
      */
     // Заголовок списка товаров
     self::templateVar('product_list_title', 'Последние товары');
     // товары в списке (6 последних добавленных в соотвествии с фильтром цен)
     $collection = new Collection('Product', App::currentLang()->getId());
     $collection->link('cover');
     $collection->order("`add` DESC");
     $where = "`active` = 1";
     if (isset($_POST['submitPriceRange'])) {
         $where .= " AND `price` >= {$_POST['min']} AND `price` <= {$_POST['max']}";
     }
     $collection->where($where);
     $collection->limit(6);
     self::templateVar('product_list_items', $collection->items());
     if (App::isAjax()) {
         // Если это ajax выводим чанк списка товаров
         return self::displayPage('chunks/product-list');
     }
     // Привязка категорий для табов под списком товаров
     // Получаем две категории из базы
     $collection = new Collection('Category', App::currentLang()->getId());
     $collection->where("`active` = 1");
     $collection->limit(2);
     $categories = $collection->items();
     foreach ($categories as $category) {
         $collection = new Collection('Product', App::currentLang()->getId());
         $collection->where("`id_category` = " . $category->getId() . " AND `active` = 1");
         $collection->limit(4);
         $category->setLink('products', $collection->items());
     }
     foreach ($categories as $index => $category) {
         if (empty($category->products)) {
             unset($categories[$index]);
         }
     }
     // Привязываем к шаблону
     static::templateVar('tab_categories', $categories);
     return self::displayPage('index');
 }
开发者ID:swash13,项目名称:shop,代码行数:47,代码来源:Index.php

示例9: actionSearch

 protected static function actionSearch()
 {
     // Заголовок над списком твоаров
     self::templateVar('product_list_title', 'Результаты поиска');
     // Товары
     $products = new Collection('Product', App::currentLang()->getId());
     $products->link('cover');
     $products->where("`active` = 1 AND `name` LIKE '%{$_GET['q']}%'" . (isset($_POST['submitPriceRange']) ? " AND `price` >= {$_POST['min']} AND `price` <= {$_POST['max']}" : ''));
     $products->order("`add` DESC");
     $products->limit(12);
     self::templateVar('product_list_items', $products->items());
     // Если это ajax выводим только чанк product-list
     if (App::isAjax()) {
         return self::displayPage('chunks/product-list');
     }
     return self::displayPage('catalog');
 }
开发者ID:swash13,项目名称:shop,代码行数:17,代码来源:Catalog.php

示例10: testWhere

 public function testWhere()
 {
     $this->object[0];
     // initialize collection
     $this->assertTrue($this->object->isLoaded());
     // change conditions
     $this->object->where("[allowed] = %b", false);
     $this->assertFalse($this->object->isLoaded());
     // test result
     $i = 0;
     foreach ($this->object as $item) {
         $this->assertEquals(false, $item->allowed);
         $i++;
     }
     $this->assertEquals(2, $i);
     // change conditions
     $this->object->where("[name] = %s", "Article");
     $this->assertEquals(1, count($this->object));
 }
开发者ID:janmarek,项目名称:Ormion,代码行数:19,代码来源:CollectionTest.php

示例11: init

 protected static function init()
 {
     parent::init();
     /*
      * Если текущий запрос не ajax
      * Происходит привязка глобальных данных для левого меню
      */
     if (!App::isAjax()) {
         // Привязка списка категорий
         $collection = new Collection('Category', App::currentLang()->getId());
         $collection->where("`active` = 1");
         static::templateGlobal('aside_categories', $collection->items());
         // Привязка списка производителей
         $collection = new Collection('Brand', App::currentLang()->getId());
         $collection->where("`active` = 1");
         static::templateGlobal('aside_brands', $collection->items());
         // Привязка данных для фильтра цен
         static::templateGlobal('filter_price', Database::getRow("\n                SELECT\n                    MIN(`price`) AS `min`,\n                    MAX(`price`) AS `max`\n                FROM `product`\n                WHERE `active` = 1\n            "));
     }
 }
开发者ID:swash13,项目名称:shop,代码行数:20,代码来源:ControllerAside.php

示例12: getDoctorsListCount

 public function getDoctorsListCount($latitude = 0, $longitude = 0, $query = array())
 {
     $this->data = DB::table('doctors');
     $this->data->leftJoin('doctors_details AS dhospital', 'doctors.id', '=', 'dhospital.doctor_id');
     $this->data->leftJoin('listing_hospitals', 'dhospital.detail_id', '=', 'listing_hospitals.id');
     $this->data->leftJoin('doctors_details AS dhmo', 'doctors.id', '=', 'dhmo.doctor_id');
     $this->data->leftJoin('listing_hmo', 'dhmo.detail_id', '=', 'listing_hmo.id');
     $this->data->leftJoin('doctors_specialization', 'doctors.id', '=', 'doctors_specialization.doctor_id');
     $this->data->leftJoin('location_cities', 'listing_hospitals.city', '=', 'location_cities.id');
     $this->data->leftJoin('location_provinces', 'listing_hospitals.province', '=', 'location_provinces.id');
     $this->data->select(DB::raw("doctors.*, dhospital.detail_id as hospital_id, listing_hospitals.listing_title as hospital_title, listing_hospitals.latitude, listing_hospitals.longitude, listing_hospitals.street, location_cities.city_name, location_provinces.province_name, dhmo.detail_id as hmo_id, listing_hmo.listing_title as hmo_title, doctors_specialization.specialization_id, (6371 * acos (cos ( radians(?) ) * cos( radians( listing_hospitals.latitude ) ) * cos( radians( listing_hospitals.longitude ) - radians(?) ) + sin ( radians(?) ) * sin( radians( listing_hospitals.latitude ) ))) AS distance"))->setBindings([$latitude, $longitude, $latitude]);
     $this->data->where('dhospital.detail_type', '=', 1);
     $this->data->where('dhmo.detail_type', '=', 4);
     if (isset($query['specializations'])) {
         $this->data->whereIn('doctors_specialization.specialization_id', $query['specializations']);
     }
     if (isset($query['locations'])) {
         $this->data->whereIn('listing_hospitals.city', $query['locations']);
     }
     $this->data->groupBy('doctors.id');
     // }
     return $this->data->get();
 }
开发者ID:pbanjoplasabas,项目名称:mydoctorfinder,代码行数:23,代码来源:Doctors.php

示例13: load_products

 public static function load_products()
 {
     if (!Config::$cart_table) {
         return;
     }
     # create a collection for the products table
     $col = new Collection(Config::$cart_table);
     # loop through the products in the cart
     foreach (self::get_cart() as $id => $qty) {
         # select those products by their ids
         # field, value, use_quotes, or
         $col->where('id', $id, true, true);
     }
     # if there is any products in the cart at all
     if ($_SESSION[Config::$sitename]['cart'][Auth::user_id()]) {
         # then load them all into the collection
         $col->get();
     }
     # clear the static products array
     self::$products = [];
     # for each item in the collection
     foreach ($col->items as $product) {
         # add a quantity property to the model
         $product->quantity = $_SESSION[Config::$sitename]['cart'][Auth::user_id()][$product->id];
         # add the product object into the products array
         self::$products[] = $product;
     }
 }
开发者ID:sean01,项目名称:pokecart,代码行数:28,代码来源:cart.lib.php

示例14: getAllChildren

 /**
  * Return an array of all children of the current category
  *
  * @param int $id_lang
  * @return Collection
  */
 public function getAllChildren($id_lang = null)
 {
     if (is_null($id_lang)) {
         $id_lang = Context::getContext()->language->id;
     }
     $categories = new Collection('Category', $id_lang);
     $categories->where('nleft', '>', $this->nleft);
     $categories->where('nright', '<', $this->nright);
     return $categories;
 }
开发者ID:jicheng17,项目名称:pengwine,代码行数:16,代码来源:Category.php

示例15: getStockCollection

 /**
  * For a given product, retrieves the stock collection
  *
  * @param int $id_product
  * @param int $id_product_attribute
  * @param int $id_warehouse Optional
  * @param int $price_te Optional
  * @return Collection of Stock
  */
 protected function getStockCollection($id_product, $id_product_attribute, $id_warehouse = null, $price_te = null)
 {
     $stocks = new Collection('Stock');
     $stocks->where('id_product', '=', $id_product);
     $stocks->where('id_product_attribute', '=', $id_product_attribute);
     if ($id_warehouse) {
         $stocks->where('id_warehouse', '=', $id_warehouse);
     }
     if ($price_te) {
         $stocks->where('price_te', '=', $price_te);
     }
     return $stocks;
 }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:22,代码来源:StockManager.php


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