当前位置: 首页>>代码示例>>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;未经允许,请勿转载。