當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Products::find方法代碼示例

本文整理匯總了PHP中Products::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP Products::find方法的具體用法?PHP Products::find怎麽用?PHP Products::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Products的用法示例。


在下文中一共展示了Products::find方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: searchAction

 public function searchAction()
 {
     $numberPage = 1;
     if ($this->request->isPost()) {
         $query = Phalcon_Model_Query::fromInput("Products", $_POST);
         $this->session->conditions = $query->getConditions();
     } else {
         $numberPage = $this->request->getQuery("page", "int");
         if ($numberPage <= 0) {
             $numberPage = 1;
         }
     }
     $parameters = array();
     if ($this->session->conditions) {
         $parameters["conditions"] = $this->session->conditions;
     }
     $parameters["order"] = "id";
     $products = Products::find($parameters);
     if (count($products) == 0) {
         Flash::notice("The search did not find any products", "alert alert-info");
         return $this->_forward("products/index");
     }
     $paginator = Phalcon_Paginator::factory("Model", array("data" => $products, "limit" => 5, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
     $this->view->setVar("products", $products);
 }
開發者ID:racklin,項目名稱:invo,代碼行數:27,代碼來源:ProductsController.php

示例2: searchAction

 public function searchAction()
 {
     $numberPage = 1;
     if ($this->request->isPost()) {
         $query = Criteria::fromInput($this->di, "Products", $_POST);
         $this->persistent->searchParams = $query->getParams();
     } else {
         $numberPage = $this->request->getQuery("page", "int");
         if ($numberPage <= 0) {
             $numberPage = 1;
         }
     }
     $parameters = array();
     if ($this->persistent->searchParams) {
         $parameters = $this->persistent->searchParams;
     }
     $products = Products::find($parameters);
     if (count($products) == 0) {
         $this->flash->notice("The search did not find any products");
         return $this->forward("products/index");
     }
     $paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $products, "limit" => 5, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
 }
開發者ID:Rho1and0,項目名稱:invo,代碼行數:25,代碼來源:ProductsController.php

示例3: deleteAction

 /**
  * Delete a customer record
  */
 public function deleteAction()
 {
     $productsTable = new Products();
     $product = $productsTable->find($this->_getParam('id'))->current();
     !is_null($product) && $product->delete();
     $this->_redirect('/products');
 }
開發者ID:carriercomm,項目名稱:billing-6,代碼行數:10,代碼來源:ProductsController.php

示例4: updateStock

 public static function updateStock($productId)
 {
     $product = Products::find($productId);
     $stockQuantity = Stocks::whereProductId($productId)->sum('quantity');
     $soldQuantity = SalesItems::where('product_id', '=', $productId)->sum('quantity');
     $product->quantity = $stockQuantity - $soldQuantity;
     $product->save();
 }
開發者ID:nurulimamnotes,項目名稱:point-of-sale,代碼行數:8,代碼來源:Products.php

示例5: indexAction

 public function indexAction()
 {
     $indexProducts = Products::find(array("limit" => 5, "order" => "id asc"));
     $products = Products::find(array("order" => "id asc"));
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $products, "limit" => 8, "page" => $dynamicPageBegin));
     $this->view->page = $paginator->getPaginate();
     $this->view->indexProducts = $indexProducts;
 }
開發者ID:lookingatsky,項目名稱:zhonghewanbang,代碼行數:8,代碼來源:ServiceController.php

示例6: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function edit($id)
 {
     $discountTypes = ['' => 'Select Discount Type', 'percentage' => 'Percentage', 'fixed' => 'Fixed'];
     $statuses = Discounts::$statuses;
     $discount = Discounts::find($id);
     $product = Products::find($discount->product_id);
     return View::make('discounts.edit', compact('discountTypes', 'product', 'statuses', 'discount'));
 }
開發者ID:nurulimamnotes,項目名稱:point-of-sale,代碼行數:14,代碼來源:DiscountsController.php

示例7: indexAction

 public function indexAction()
 {
     $currentPage = 1;
     $currentPage = $this->request->get("page");
     $products = Products::find();
     $paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => $products, "limit" => 4, "page" => $currentPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
 }
開發者ID:sayi21cn,項目名稱:haitao,代碼行數:9,代碼來源:ProductsController.php

示例8: findProductCoalesced

 /**
  * @param int $customerId
  * @param int $productId
  */
 public function findProductCoalesced($customerId, $productId)
 {
     $productsTable = new Products();
     $p = $productsTable->find($productId)->current();
     $cp = $this->find($productId, $customerId)->current();
     if ($cp) {
         $productCoalesced = array('product_id' => $cp->product_id, 'sku' => $cp->sku ?: $p->sku, 'name' => $cp->name ?: $p->name, 'description' => $cp->description ?: $p->description, 'unit_price' => $cp->unit_price ?: $p->unit_price);
     } else {
         $productCoalesced = array('product_id' => $p->product_id, 'sku' => $p->sku, 'name' => $p->name, 'description' => $p->description, 'unit_price' => $p->unit_price);
     }
     return $productCoalesced;
 }
開發者ID:carriercomm,項目名稱:billing-6,代碼行數:16,代碼來源:CustomerProducts.php

示例9: indexAction

 public function indexAction()
 {
     $news1 = News::find(array("typeid = 1", "order" => "inputtime desc", "limit" => 5));
     $news2 = News::find(array("typeid = 2", "order" => "inputtime desc", "limit" => 5));
     $news3 = News::find(array("typeid = 3", "order" => "inputtime desc", "limit" => 3));
     $news4 = News::find(array("typeid = 4", "order" => "inputtime desc", "limit" => 5));
     $indexProducts = Products::find(array("limit" => 5, "order" => "id asc"));
     $this->view->indexProducts = $indexProducts;
     $this->view->setVar("news1", $news1);
     $this->view->setVar("news2", $news2);
     $this->view->setVar("news3", $news3);
     $this->view->setVar("news4", $news4);
 }
開發者ID:lookingatsky,項目名稱:zhonghewanbang,代碼行數:13,代碼來源:IndexController.php

示例10: findByName

 public static function findByName($name)
 {
     $response = new Response();
     if (!$name) {
         $response->status = $response::STATUS_BAD_REQUEST;
         $response->addError('NAME_IS_REQUIRED');
         return $response->toArray();
     }
     try {
         $response->data = Products::find(['conditions' => 'name LIKE :name:', 'bind' => ['name' => '%' . $name . '%'], 'order' => 'name DESC'])->toArray();
     } catch (Exception $e) {
         $response->setException($e);
     } finally {
         return $response->toArray();
     }
 }
開發者ID:ynijar,項目名稱:products,代碼行數:16,代碼來源:ProductsService.php

示例11: array

<?php

// Using data from a resultset
echo $this->tag->select(array("productId", Products::find("type = 'vegetables'"), "using" => array("id", "name")));
// Using data from an array
echo $this->tag->selectStatic(array("status", array("A" => "Active", "I" => "Inactive")));
開發者ID:aodkrisda,項目名稱:phalcon-code,代碼行數:6,代碼來源:tags-193.php

示例12: array

<?php

//Passing a resultset as data
$paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => Products::find(), "limit" => 10, "page" => $currentPage));
//Passing an array as data
$paginator = new \Phalcon\Paginator\Adapter\Model(array("data" => array(array('id' => 1, 'name' => 'Artichoke'), array('id' => 2, 'name' => 'Carrots'), array('id' => 3, 'name' => 'Beet'), array('id' => 4, 'name' => 'Lettuce'), array('id' => 5, 'name' => '')), "limit" => 2, "page" => $currentPage));
//Passing a querybuilder as data
$builder = $this->modelsManager->createBuilder()->columns('id, name')->from('Robots')->orderBy('name');
$paginator = new Phalcon\Paginator\Adapter\QueryBuilder(array("builder" => $builder, "limit" => 20, "page" => 1));
開發者ID:aodkrisda,項目名稱:phalcon-code,代碼行數:9,代碼來源:pagination-84.php

示例13: initialize

{
    // fields
    public $id;
    public $name;
    public function initialize()
    {
        // $this->setSource("the_robots");
    }
}
// Find record with id = 3
$robot = Robots::findFirst(3);
// *** paginator ***
use Phalcon\Paginator\Adapter\Model as ModelPaginator;
use Phalcon\Paginator\Adapter\NativeArray as ArrayPaginator;
use Phalcon\Paginator\Adapter\QueryBuilder as BuildPaginator;
//Passing a resultset as data
$paginator = new ModelPaginator(array("data" => Products::find(), "limit" => 10, "page" => $currentPage));
//Passing an array as data
$paginator = new ArrayPaginator(array("data" => array(array('id' => 1, 'name' => 'Artichoke'), array('id' => 2, 'name' => 'Carrots'), array('id' => 3, 'name' => 'Beet'), array('id' => 4, 'name' => 'Lettuce'), array('id' => 5, 'name' => '')), "limit" => 2, "page" => $currentPage));
$builder = $this->modelsManager->createBuilder()->from("App\\Models\\Article")->where($where)->orderBy("create_time DESC");
$paginator = new BuildPaginator(array("builder" => $builder, "limit" => 5, "page" => $this->request->queryPage()));
$dataset = $paginator->getPaginate();
/*
items       The set of records to be displayed at the current page
current     The current page
before      The previous page to the current one
next        The next page to the current one
last        The last page in the set of records
total_pages The number of pages
total_items The number of items in the source data
//*/
開發者ID:LWFeng,項目名稱:xnx,代碼行數:31,代碼來源:model.php

示例14:

<?php

$products = Products::find($parameters);
if (count($products) == 0) {
    $this->flash->notice("The search did not found any products");
    return $this->forward("products/index");
}
開發者ID:aodkrisda,項目名稱:phalcon-code,代碼行數:7,代碼來源:tutorial-invo-778.php

示例15: returnitem

 public function returnitem($id)
 {
     $sales = SalesItems::where('sales_id', '=', $id)->get();
     if ($sales) {
         foreach ($sales as $sale) {
             if ($this->user->outlet_id != 0) {
                 $outletstock = OutletsStocks::where('product_id', '=', $sale->product_id)->where('outlet_id', '=', $this->user->outlet_id)->first();
                 if ($outletstock) {
                     $outletstock->quantity = $outletstock->quantity + $sale->quantity;
                     $outletstock->save();
                     SalesItems::destroy($sale->id);
                 }
             } else {
                 $product = Products::find($sale->product_id);
                 if ($product) {
                     // var_dump($product);exit();
                     $product->quantity = $product->quantity + $sale->quantity;
                     $product->save();
                     SalesItems::destroy($sale->id);
                 }
             }
         }
         Sales::destroy($id);
         return Redirect::route('sales.index')->with('success', 'Item successfully return');
     }
 }
開發者ID:nurulimamnotes,項目名稱:point-of-sale,代碼行數:26,代碼來源:SalesController.php


注:本文中的Products::find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。