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


PHP Stock::order_by方法代码示例

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


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

示例1: array

 function index_get()
 {
     $filters = $this->get("filter")["filters"];
     $page = $this->get('page') !== false ? $this->get('page') : 1;
     $limit = $this->get('limit') !== false ? $this->get('limit') : 100;
     $sort = $this->get("sort");
     $data["results"] = array();
     $data["count"] = 0;
     $obj = new Stock(null, $this->entity);
     //Sort
     if (!empty($sort) && isset($sort)) {
         foreach ($sort as $value) {
             $obj->order_by($value["field"], $value["dir"]);
         }
     }
     //Filter
     if (!empty($filters) && isset($filters)) {
         $deleted = 0;
         foreach ($filters as $value) {
             if (!empty($value["operator"]) && isset($value["operator"])) {
                 if ($value["operator"] == "where_in") {
                     $obj->where_in($value["field"], $value["value"]);
                 } else {
                     if ($value["operator"] == "or_where_in") {
                         $obj->or_where_in($value["field"], $value["value"]);
                     } else {
                         if ($value["operator"] == "where_not_in") {
                             $obj->where_not_in($value["field"], $value["value"]);
                         } else {
                             if ($value["operator"] == "or_where_not_in") {
                                 $obj->or_where_not_in($value["field"], $value["value"]);
                             } else {
                                 if ($value["operator"] == "like") {
                                     $obj->like($value["field"], $value["value"]);
                                 } else {
                                     if ($value["operator"] == "or_like") {
                                         $obj->or_like($value["field"], $value["value"]);
                                     } else {
                                         if ($value["operator"] == "not_like") {
                                             $obj->not_like($value["field"], $value["value"]);
                                         } else {
                                             if ($value["operator"] == "or_not_like") {
                                                 $obj->or_not_like($value["field"], $value["value"]);
                                             } else {
                                                 if ($value["operator"] == "startswith") {
                                                     $obj->like($value["field"], $value["value"], "after");
                                                 } else {
                                                     if ($value["operator"] == "endswith") {
                                                         $obj->like($value["field"], $value["value"], "before");
                                                     } else {
                                                         if ($value["operator"] == "contains") {
                                                             $obj->like($value["field"], $value["value"], "both");
                                                         } else {
                                                             if ($value["operator"] == "or_where") {
                                                                 $obj->or_where($value["field"], $value["value"]);
                                                             } else {
                                                                 if ($value["operator"] == "by_category") {
                                                                     $obj->where_related("product", $value["field"], $value["value"]);
                                                                 } else {
                                                                     $obj->where($value["field"] . ' ' . $value["operator"], $value["value"]);
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             } else {
                 if ($value["field"] == "deleted") {
                     $deleted = $value["value"];
                 } else {
                     $obj->where($value["field"], $value["value"]);
                 }
             }
         }
         $obj->where("deleted", $deleted);
     }
     //Results
     $obj->get_paged_iterated($page, $limit);
     $data["count"] = $obj->paged->total_rows;
     if ($obj->result_count() > 0) {
         foreach ($obj as $value) {
             //Fullname
             $c = new Contact(null, $this->entity);
             $c = $value->contact->get();
             $fullname = $c->surname . ' ' . $c->name;
             if ($c->contact_type_id == 3 || $c->contact_type_id == 5) {
                 $fullname = $c->company;
             }
             $data["results"][] = array("id" => $value->id, "currency_id" => $value->currency_id, "bill_id" => $value->bill_id, "contact_id" => $value->contact_id, "product_id" => $value->product_id, "unit_id" => $value->unit_id, "quantity" => floatval($value->quantity), "price" => floatval($value->price), "issued_date" => $value->issued_date, "deleted" => $value->deleted, "currency" => $value->currency->get_raw()->result(), "bill" => $value->bill->get_raw()->result(), "fullname" => $fullname, "product" => $value->product->get_raw()->result(), "unit" => $value->unit->get()->name);
         }
     }
     //Response Data
     $this->response($data, 200);
//.........这里部分代码省略.........
开发者ID:nicarayz,项目名称:linabiz,代码行数:101,代码来源:stocks.php


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