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


PHP Products::findFirst方法代码示例

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


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

示例1: productAction

 public function productAction($id)
 {
     if ($id) {
         $product = Products::findFirst("id =" . $id);
         $this->view->product = $product;
     } else {
         $this->response->redirect("/service/index");
     }
 }
开发者ID:lookingatsky,项目名称:zhonghewanbang,代码行数:9,代码来源:ServiceController.php

示例2: updateAction

 public function updateAction()
 {
     $this->view->disable();
     $product = Products::findFirst($this->request->getPost("id"));
     $product->category_id = intval($this->request->getPost("category_id"));
     $product->status = $this->request->getPost("status");
     if ($product->save()) {
         echo json_encode(array("status" => "OK"));
     } else {
         echo json_encode(array("status" => "NG"));
     }
 }
开发者ID:vietdh85,项目名称:product-vh,代码行数:12,代码来源:ProductsController.php

示例3: update

 public static function update($id, $data)
 {
     $response = new Response();
     try {
         $data = json_decode($data, true);
         $category = Categories::findFirst($data->categoryId);
         if ($category !== FALSE) {
             /** @var Products $products */
             $product = Products::findFirst($id);
             $product->setAttributes($data);
             $response->data = $product->update();
         } else {
             $response->status = $response::STATUS_BAD_REQUEST;
             $response->addError('CATEGORIES_NOT_FOUND');
         }
     } catch (Exception $e) {
         $response->setException($e);
     } finally {
         return $response->toArray();
     }
 }
开发者ID:ynijar,项目名称:products,代码行数:21,代码来源:ProductsService.php

示例4: deleteAction

 public function deleteAction($id)
 {
     $id = $this->filter->sanitize($id, array("int"));
     $products = Products::findFirst('id="' . $id . '"');
     if (!$products) {
         $this->flash->error("Product was not found");
         return $this->forward("products/index");
     }
     if (!$products->delete()) {
         foreach ($products->getMessages() as $message) {
             $this->flash->error((string) $message);
         }
         return $this->forward("products/search");
     } else {
         $this->flash->success("Products was deleted");
         return $this->forward("products/index");
     }
 }
开发者ID:Rho1and0,项目名称:invo,代码行数:18,代码来源:ProductsController.php

示例5: indexAction

 public function indexAction()
 {
     $this->view->product = Products::findFirst();
 }
开发者ID:boiler256,项目名称:mvc,代码行数:4,代码来源:ProductsController.php

示例6: indexAction

 public function indexAction()
 {
     $this->view->setVar('product', Products::findFirst());
 }
开发者ID:abuelezz,项目名称:mvc,代码行数:4,代码来源:ProductsController.php

示例7: getProductAction

 public function getProductAction()
 {
     if (ApiController::access()) {
         if (isset($_POST['id'])) {
             $product = Products::findFirst($this->request->getPost('id'));
         } else {
             $product = Products::find();
         }
         if ($product != false) {
             foreach ($product as $row) {
                 $response[$row->name]['name'] = $row->name;
                 $response[$row->name]['category'] = $row->category;
                 $response[$row->name]['description'] = $row->description;
             }
             echo json_encode($response);
         }
         $this->view->disable();
     }
 }
开发者ID:groumand,项目名称:restAPI-php-phalcon,代码行数:19,代码来源:ApiController.php


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