本文整理汇总了PHP中Product::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::select方法的具体用法?PHP Product::select怎么用?PHP Product::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product::select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cart
/**
* [cart description]
* @return [type] [description]
*/
private function cart()
{
foreach (Session::get('array_slug') as $key => $slug) {
$value = Product::select('id', 'name', 'image_small', 'price', 'price_sale', 'price_bestsaller', 'slug')->whereSlug($slug)->first();
$product[$key]['id'] = $value['id'];
$product[$key]['name'] = $value['name'];
$product[$key]['image_small'] = $value['image_small'];
$product[$key]['slug'] = $value['slug'];
if ($value['price_bestsaller'] != 0) {
$price = round($value['price'] - $value['price'] * $value['price_bestsaller'] / 100);
} elseif ($value['price_sale'] != 0) {
$price = round($value['price'] - $value['price'] * $value['price_sale'] / 100);
} else {
$price = $value['price'];
}
$product[$key]['price'] = $price;
}
$total = 0;
foreach ($product as $item) {
$total += (int) $item['price'];
}
$data['products'] = $product;
$data['total'] = $total;
return $data;
}
示例2: getProducts
public function getProducts()
{
$products = Product::select('id', 'product_key', 'notes', 'pack_types', 'is_product', 'ice', 'units', 'cc')->orderBy('product_key', 'ASC')->get();
foreach ($products as $key => $product) {
$product->pack_types = $product->pack_types == 1 ? "Vidrio" : "Plástico";
$product->ice = $product->ice ? "SÍ" : "NO";
$product->accion = "<a class='btn btn-primary btn-xs' data-task='view' href='productos/{$product->id}' style='text-decoration:none;color:white;'><i class='glyphicon glyphicon-eye-open'></i></a> <a class='btn btn-warning btn-xs' href='productos/{$product->id}/edit' style='text-decoration:none;color:white;'><i class='glyphicon glyphicon-edit'></i></a>";
}
$productJson = ['data' => $products];
return Response::json($productJson);
}
示例3: index
public function index()
{
$this->load->helper('filter');
$quantity_addition = new Product_quantity();
$quantity_addition->select_sum('quantity', 'quantity_sum');
$quantity_addition->where('type', Product_quantity::TYPE_ADDITION);
$quantity_addition->where_related('product', 'id', '${parent}.id');
$quantity_subtraction = new Product_quantity();
$quantity_subtraction->select_sum('quantity', 'quantity_sum');
$quantity_subtraction->where('type', Product_quantity::TYPE_SUBTRACTION);
$quantity_subtraction->where_related('operation', 'type', Operation::TYPE_SUBTRACTION);
$quantity_subtraction->where_related('operation', 'subtraction_type', Operation::SUBTRACTION_TYPE_PRODUCTS);
$quantity_subtraction->where_related('product', 'id', '${parent}.id');
$products = new Product();
$products->order_by('title', 'asc');
$products->select('*');
$products->select_subquery($quantity_addition, 'plus_quantity');
$products->select_subquery($quantity_subtraction, 'minus_quantity');
$products->get_iterated();
$this->parser->parse('web/controllers/products/index.tpl', array('title' => 'Administrácia / Bufet', 'new_item_url' => site_url('products/new_product'), 'products' => $products));
}
示例4: bufet
public function bufet()
{
$this->load->helper('operations');
$multiplier = operations_ledcoin_multiplier();
$quantity_addition = new Product_quantity();
$quantity_addition->select_sum('quantity', 'quantity_sum');
$quantity_addition->where('type', Product_quantity::TYPE_ADDITION);
$quantity_addition->where_related('product', 'id', '${parent}.id');
$quantity_subtraction = new Product_quantity();
$quantity_subtraction->select_sum('quantity', 'quantity_sum');
$quantity_subtraction->where('type', Product_quantity::TYPE_SUBTRACTION);
$quantity_subtraction->where_related('product', 'id', '${parent}.id');
$products = new Product();
$products->order_by('price', 'asc');
$products->select('*');
$products->select_subquery($quantity_addition, 'plus_quantity');
$products->select_subquery($quantity_subtraction, 'minus_quantity');
$products->get_iterated();
$this->parser->parse('web/controllers/ledcoin/bufet.tpl', array('products' => $products, 'title' => 'Bufet', 'multiplier' => $multiplier));
}
示例5: listFavoriteProduct
public function listFavoriteProduct()
{
$token = Input::get('token', '');
$u_id = Input::get('u_id');
$per_page = Input::get('per_page', 0);
try {
$user = User::chkUserByToken($token, $u_id);
$list = Product::select('products.*', 'favorites.created_at')->with(['user' => function ($q) {
$q->with(['school']);
}, 'praises' => function ($q) {
$q->where('praises.u_id', '=', $this->u_id);
}])->join('favoriables', function ($q) {
$q->on('products.p_id', '=', 'favoriables.favoriable_id')->where('favoriables.favoriable_type', '=', 'Product');
})->join('favorites', function ($q) {
$q->on('favorites.id', '=', 'favoriables.favorite_id')->where('favorites.u_id', '=', $this->u_id);
})->orderBy('favorites.created_at', 'DESC')->paginate($per_page);
$data = [];
foreach ($list as $key => $product) {
$tmp = $product->showInList();
$tmp['is_praised'] = 0;
if (count($product->praises) > 0) {
$tmp['is_praised'] = 1;
}
$data[] = $tmp;
}
$re = Tools::reTrue('获取收藏列表成功', $data);
} catch (Exception $e) {
$re = Tools::reFalse($e->getCode(), '获取收藏列表失败:' . $e->getMessage());
}
return Response::json($re);
}
示例6: json_encode
<?php
/**
* StitchLite Product API
* Access Product information
* Pass querystring paramter 'sku' with value
* corresponding to product SKU to filter data
*/
require_once $_SERVER['DOCUMENT_ROOT'] . '/const/site.constants.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/database.class.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/table.class.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/product.class.php';
$querystring = $_SERVER["QUERY_STRING"];
/**
* Parse querystring data and return
* key-value pairs to array $qsArray
*/
parse_str($querystring, $qsArray);
$product = new Product();
$product->select($qsArray);
/**
* Store results in JSON format for output
*/
$results = $product->prepare_for_json($product->resultset());
echo json_encode($results, JSON_PRETTY_PRINT);
示例7: getTotalPageByKey
public static function getTotalPageByKey($key, $take)
{
$key = trim($key);
$key = explode("+", $key);
$raw_query = '';
foreach ($key as $index => $value) {
if ($index == 0) {
$raw_query .= '`name` like "%' . $value . '%" or `short_name` like "%' . $value . '%" ';
} else {
$raw_query .= 'or `name` like "%' . $value . '%" or `short_name` like "%' . $value . '%" ';
}
}
$total = Product::select('id')->whereRaw($raw_query)->where('active', 1)->count('id');
return round($total / $take);
}
示例8: getProducts
public function getProducts()
{
$products = Product::select()->getList();
return Response::json($products);
}
示例9: get_form
public function get_form($type = '', $subtraction_type = '')
{
$this->load->helper('operations');
$operations_addition = new Operation();
$operations_addition->where('type', Operation::TYPE_ADDITION);
$operations_addition->select_sum('amount', 'amount_sum');
$operations_addition->where_related_person('id', '${parent}.id');
$operations_subtraction_direct = new Operation();
$operations_subtraction_direct->where('type', Operation::TYPE_SUBTRACTION);
$operations_subtraction_direct->where('subtraction_type', Operation::SUBTRACTION_TYPE_DIRECT);
$operations_subtraction_direct->select_sum('amount', 'amount_sum');
$operations_subtraction_direct->where_related_person('id', '${parent}.id');
$operations_subtraction_products = new Operation();
$operations_subtraction_products->where('type', Operation::TYPE_SUBTRACTION);
$operations_subtraction_products->where('subtraction_type', Operation::SUBTRACTION_TYPE_PRODUCTS);
$operations_subtraction_products->where_related('product_quantity', 'price >', 0);
$operations_subtraction_products->group_start(' NOT', 'AND');
$operations_subtraction_products->where_related('product_quantity', 'product_id', NULL);
$operations_subtraction_products->group_end();
unset($operations_subtraction_products->db->ar_select[0]);
$operations_subtraction_products->select_func('SUM', array('@product_quantities.quantity', '*', '@product_quantities.price', '*', '@product_quantities.multiplier'), 'amount_sum');
$operations_subtraction_products->where_related_person('id', '${parent}.id');
$operations_subtraction_services = new Operation();
$operations_subtraction_services->where('type', Operation::TYPE_SUBTRACTION);
$operations_subtraction_services->where('subtraction_type', Operation::SUBTRACTION_TYPE_SERVICES);
$operations_subtraction_services->where_related('service_usage', 'price >', 0);
$operations_subtraction_services->group_start(' NOT', 'AND');
$operations_subtraction_services->where_related('service_usage', 'service_id', NULL);
$operations_subtraction_services->group_end();
unset($operations_subtraction_services->db->ar_select[0]);
$operations_subtraction_services->select_func('SUM', array('@service_usages.quantity', '*', '@service_usages.price', '*', '@service_usages.multiplier'), 'amount_sum');
$operations_subtraction_services->where_related_person('id', '${parent}.id');
$persons = new Person();
$persons->order_by('surname', 'asc')->order_by('name', 'asc');
$persons->where('admin', 0);
$persons->select('*');
$persons->select_subquery($operations_addition, 'plus_amount');
$persons->select_subquery($operations_subtraction_direct, 'minus_amount_direct');
$persons->select_subquery($operations_subtraction_products, 'minus_amount_products');
$persons->select_subquery($operations_subtraction_services, 'minus_amount_services');
$persons->include_related('group', 'title');
$persons->get_iterated();
$persons_select = array('' => '');
foreach ($persons as $person) {
$amount = doubleval($person->plus_amount) - intval($person->minus_amount_direct) - intval($person->minus_amount_products) - intval($person->minus_amount_services);
$persons_select[$person->id] = $person->name . ' ' . $person->surname . ' (' . $person->group_title . ' | LEDCOIN: ' . $amount . ' ' . get_inflection_ledcoin($amount) . ')';
}
$workplaces = new Workplace();
$workplaces->order_by('title', 'asc');
$workplaces->get_iterated();
$workplaces_select = array('' => '');
foreach ($workplaces as $workplace) {
$workplaces_select[$workplace->id] = $workplace->title;
}
$form = array('fields' => array('type' => array('name' => 'operation[type]', 'type' => 'select', 'id' => 'operation-type', 'label' => 'Typ operácie', 'data' => array('stay-visible' => 'true'), 'values' => array('' => '', Operation::TYPE_ADDITION => 'Pridanie LEDCOIN-u', Operation::TYPE_SUBTRACTION => 'Odobratie LEDCOIN-u'), 'validation' => 'required'), 'subtraction_type' => array('name' => 'operation[subtraction_type]', 'type' => 'select', 'id' => 'operation-subtraction_type', 'label' => 'Spôsob odobratia LEDCOIN-u', 'data' => array('stay-visible' => 'true'), 'values' => array('' => '', Operation::SUBTRACTION_TYPE_DIRECT => 'Priame odobratie LEDCOIN-u', Operation::SUBTRACTION_TYPE_PRODUCTS => 'Nákup v bufete', Operation::SUBTRACTION_TYPE_SERVICES => 'Využitie služieb'), 'validation' => 'required'), 'addition_type' => array('name' => 'operation[addition_type]', 'type' => 'select', 'id' => 'operation-addition_type', 'data' => array('stay-visivle' => 'true'), 'label' => 'Spôsob pridania LEDCOIN-u', 'values' => array('' => '', Operation::ADDITION_TYPE_TRANSFER => 'Prevod z účtu vedúcich', Operation::ADDITION_TYPE_MINING => 'Vydolovanie LEDCOIN-u'), 'validation' => 'required'), 'person' => array('name' => 'operation[person_id]', 'type' => 'select', 'id' => 'operation-person_id', 'label' => 'Účastník', 'data' => array('stay-visible' => 'true'), 'values' => $persons_select, 'validation' => 'required'), 'workplace' => array('name' => 'operation[workplace_id]', 'type' => 'select', 'id' => 'operation-workplace_id', 'data' => array('stay-visible' => 'true'), 'label' => 'Zamestnanie', 'values' => $workplaces_select), 'comment' => array('name' => 'operation[comment]', 'type' => 'text_input', 'id' => 'comment-id', 'label' => 'Komentár', 'data' => array('stay-visible' => 'true'), 'validation' => 'max_length[255]'), 'amount' => array('name' => 'operation[amount]', 'type' => 'slider', 'id' => 'comment-amount', 'label' => 'LEDCOIN', 'data' => array('stay-visible' => 'true'), 'min' => 0, 'max' => 25, 'step' => 0.1, 'default' => 0, 'validation' => array(array('if-field-not-equals' => array('field' => 'operation[amount]', 'value' => 0), 'rules' => 'required|floatpoint|convert_floatpoint|greater_than[0]'))), 'multiplier-fake' => array('name' => 'operation[multiplier-fake]', 'type' => 'text_input', 'disabled' => true, 'id' => 'operation-multiplier-fake', 'default' => operations_ledcoin_multiplier(), 'label' => 'Multiplikátor LEDCOIN-u'), 'multiplier' => array('name' => 'operation[multiplier]', 'type' => 'hidden', 'default' => operations_ledcoin_multiplier())), 'arangement' => array('type', 'person', 'workplace', 'comment'));
if ($type == Operation::TYPE_SUBTRACTION) {
if ($subtraction_type == Operation::SUBTRACTION_TYPE_DIRECT) {
$form['arangement'] = array('type', 'subtraction_type', 'person', 'workplace', 'comment', 'amount');
} elseif ($subtraction_type == Operation::SUBTRACTION_TYPE_SERVICES) {
$form['arangement'] = array('type', 'subtraction_type', 'person', 'comment', 'multiplier', 'multiplier-fake');
$services = new Service();
$services->order_by('title', 'asc');
$services->get_iterated();
foreach ($services as $service) {
$form['fields']['service_' . $service->id . '_quantity'] = array('name' => 'operation_service[' . $service->id . '][quantity]', 'class' => 'controlls-services', 'id' => 'operation_service-' . $service->id . '-quantity', 'type' => 'slider', 'min' => 0, 'max' => 240, 'label' => $service->title . ' (LEDCOIN)', 'data' => array('service-title' => $service->title), 'default' => 0, 'validation' => array(array('if-field-not-equals' => array('field' => 'operation_service[' . $service->id . '][quantity]', 'value' => 0), 'rules' => 'required|integer|greater_than[0]')));
$form['fields']['service_' . $service->id . '_price'] = array('name' => 'operation_service[' . $service->id . '][price]', 'class' => 'controlls-services', 'id' => 'operation_service-' . $service->id . '-price', 'type' => 'text_input', 'label' => $service->title . ' (cena za minútu)', 'data' => array('service-title' => $service->title), 'default' => $service->price, 'validation' => array(array('if-field-not-equals' => array('field' => 'operation_service[' . $service->id . '][quantity]', 'value' => 0), 'rules' => 'required|floatpoint|convert_floatpoint|greater_than[0]')));
$form['arangement'][] = 'service_' . $service->id . '_quantity';
$form['arangement'][] = 'service_' . $service->id . '_price';
}
} elseif ($subtraction_type == Operation::SUBTRACTION_TYPE_PRODUCTS) {
$form['arangement'] = array('type', 'subtraction_type', 'person', 'comment', 'multiplier', 'multiplier-fake');
$quantity_addition = new Product_quantity();
$quantity_addition->select_sum('quantity', 'quantity_sum');
$quantity_addition->where('type', Product_quantity::TYPE_ADDITION);
$quantity_addition->where_related('product', 'id', '${parent}.id');
$quantity_subtraction = new Product_quantity();
$quantity_subtraction->select_sum('quantity', 'quantity_sum');
$quantity_subtraction->where('type', Product_quantity::TYPE_SUBTRACTION);
$quantity_subtraction->where_related('product', 'id', '${parent}.id');
$products = new Product();
$products->order_by('title', 'asc');
$products->select('*');
$products->select_subquery($quantity_addition, 'plus_quantity');
$products->select_subquery($quantity_subtraction, 'minus_quantity');
$products->get_iterated();
$p = 1;
foreach ($products as $product) {
$form['fields']['product_' . $product->id . '_quantity'] = array('name' => 'operation_product[' . $product->id . '][quantity]', 'class' => 'controlls-products', 'id' => 'operation_product-' . $product->id . '-quantity', 'type' => 'slider', 'min' => 0, 'max' => intval($product->plus_quantity) - intval($product->minus_quantity), 'label' => '<span class="product_title_label"><img src="' . get_product_image_min($product->id) . '" alt="" /><span class="product_title">' . $product->title . ' (počet kusov)</span></span>', 'default' => 0, 'disabled' => intval($product->plus_quantity) - intval($product->minus_quantity) <= 0 ? true : false, 'data' => array('product-title' => $product->title), 'validation' => array(array('if-field-not-equals' => array('field' => 'operation_product[' . $product->id . '][quantity]', 'value' => 0), 'rules' => 'required|integer|greater_than[0]|less_than_equals[' . (intval($product->plus_quantity) - intval($product->minus_quantity)) . ']')));
$form['fields']['product_' . $product->id . '_price'] = array('name' => 'operation_product[' . $product->id . '][price]', 'class' => 'controlls-products', 'id' => 'operation_product-' . $product->id . '-price', 'type' => 'text_input', 'label' => $product->title . ' (cena za kus)', 'default' => $product->price, 'disabled' => intval($product->plus_quantity) - intval($product->minus_quantity) <= 0 ? true : false, 'data' => array('product-title' => $product->title), 'validation' => array(array('if-field-not-equals' => array('field' => 'operation_product[' . $product->id . '][quantity]', 'value' => 0), 'rules' => 'required|floatpoint|convert_floatpoint|greater_than[0]')));
$form['arangement'][] = 'product_' . $product->id . '_quantity';
$form['arangement'][] = 'product_' . $product->id . '_price';
if ($p < $products->result_count()) {
$form['fields']['product_' . $product->id . '_divider'] = array('type' => 'divider', 'data' => array('product-title' => $product->title));
$form['arangement'][] = 'product_' . $product->id . '_divider';
}
$p++;
}
} else {
$form['arangement'] = array('type', 'subtraction_type', 'person');
}
//.........这里部分代码省略.........
示例10: Paging
<?php
global $db, $messages, $home_dir;
require_once $home_dir . 'models/product.m.php';
require_once $home_dir . 'classes/paging.php';
$sellers = Product::select($db, 'viewProducts', null, null, null, new Paging(0, 4), 'RAND()');
?>
<div class="row top-sellers products">
<?php
foreach ($sellers as $product) {
renderPartial('prod-prev', $product);
}
?>
</div>
示例11:
<?php
require_once 'config.php';
if (isset($_GET['limit'])) {
$idx = $_GET['limit'];
$l = $idx - 1;
} else {
$idx = 0;
$l = 0;
}
$limit = 12;
$meta = Meta::select('catalog', $_GET['name_en']);
$records = Product::select($_GET['name_en'], $l, $limit);
$count = Product::selectCount($_GET['name_en']);
include 'view/tpl_top.php';
include 'view/tpl_header.php';
include 'view/tpl_nav.php';
?>
<div class="container main-container">
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-12">
<?php
include 'view/tpl_catalog.php';
?>
</div>
<div class="clearfix visible-sm"></div>
<div class="col-lg-9 col-md-9 col-sm-12">
<div class="col-lg-12 col-sm-12">
<span class="title text-uppercase"><?php
echo $records ? "Продукция" : "Продукция на стадии заполнения";
?>
示例12: loadCart
static function loadCart($db, $customer_id)
{
return Product::select($db, 'viewProductsInCart', 'cart_customer_id = ?', [intval($customer_id)], 'i', null, 'product_name');
}
示例13: Paging
<?php
global $home_dir, $db;
require_once $home_dir . 'models/product.m.php';
$paging = new Paging(_gi('offset'), _gi('limit'));
$sorting = _g('sorting', 'sortby_Alphabet');
$orderby = Product::getSorting($sorting);
$ids = explode(',', _g('category_ids'));
$values = [];
$types = '';
foreach ($ids as $id) {
$values[] = '?';
$types .= 'i';
}
$products = Product::select($db, 'viewProducts', sprintf('product_category_id IN (%s)', implode(',', $values)), $ids, $types, $paging, $orderby);
$data['products'] = $products;
示例14: t
<?php
require_once $home_dir . 'classes/paging.php';
require_once $home_dir . 'models/product.m.php';
global $db, $data;
$page_title = t('Search Results');
$search = _g('search');
$paging = Paging::getFromUrl();
if (isset($search)) {
$search_results = Product::select($db, 'viewProducts', 'product_name LIKE ?', ['%' . $search . '%'], 's', $paging, 'product_name');
$data['search_results'] = $search_results;
}
$data['paging'] = $paging;
示例15: buildMyProductQuery
public function buildMyProductQuery()
{
$user = \Config::get('webshoppack::logged_user_id');
$user_id = $user();
$this->qry = Product::select('Product.id', 'Product.product_code', 'Product.product_name', 'Product.product_price', 'Product.product_price_currency', 'Product.product_sold', 'Product.product_discount_price', 'Product.product_discount_fromdate', 'Product.product_discount_todate', 'Product.is_free_product', 'Product.product_status')->where('Product.product_user_id', $user_id);
$this->qry->Where('Product.product_status', '!=', 'Deleted');
if ($this->getSearchValue('search_product_code')) {
$this->qry->Where('Product.product_code', $this->getSearchValue('search_product_code'));
}
if ($this->getSearchValue('search_product_name') != '') {
$this->qry->Where('Product.product_name', 'LIKE', '%' . addslashes($this->getSearchValue('search_product_name')) . '%');
}
if ($this->getSearchValue('search_product_category') > 0) {
$cat_id_arr = $this->getSubCategoryIds($this->getSearchValue('search_product_category'));
$this->qry->whereIn('Product.product_category_id', $cat_id_arr);
}
if ($this->getSearchValue('search_product_status') != '' && $this->getSearchValue('search_product_status') != 'All') {
$this->qry->where('Product.product_status', '=', $this->getSearchValue('search_product_status'));
}
$this->qry->orderBy('Product.id', 'DESC');
return $this->qry;
}