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


PHP SSP::get_model方法代码示例

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


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

示例1: simple

 /**
  * Perform the SQL queries needed for an server-side processing requested,
  * utilising the helper functions of this class, limit(), order() and
  * filter() among others. The returned array is ready to be encoded as JSON
  * in response to an SSP request, or can be modified if needed before
  * sending back to the client.
  *
  *  @param  array $request Data sent to server by DataTables
  *  @param  array $sql_details SQL connection details - see sql_connect()
  *  @param  string $table SQL table to query
  *  @param  string $primaryKey Primary key of the table
  *  @param  array $columns Column information array
  *  @return array          Server-side processing response array
  */
 static function simple($request, $table, $primaryKey, $columns, $join = array(), $custom_where = array())
 {
     $bindings = array();
     $model = SSP::get_model();
     $fields = SSP::pluck_db($columns);
     $model->db->select("SQL_CALC_FOUND_ROWS " . $primaryKey, FALSE);
     $model->db->select($fields, FALSE);
     $model->db->from($table);
     foreach ($join as $j) {
         $model->db->join($j[0], $j[1]);
     }
     $where = SSP::filter($request, $columns, $bindings);
     if ($where != "") {
         $model->db->where($where);
     }
     if ($custom_where != "") {
         $model->db->where($custom_where);
     }
     foreach (SSP::order($request, $columns) as $order) {
         $order = explode("||", $order);
         $model->db->order_by($order[0], $order[1]);
     }
     $rows = isset($request['start']) ? $request['start'] : "";
     $limit = isset($request['length']) ? $request['length'] : 0;
     $model->db->limit($limit, $rows);
     $query = $model->db->get();
     $cquery = $model->db->query('SELECT FOUND_ROWS() AS `Count`');
     $recordsFiltered = $cquery->row()->Count;
     $data = $query->result_array();
     //print_r($data);exit;
     $query->free_result();
     $model->db->select($primaryKey);
     $model->db->from($table);
     $query = $model->db->get();
     //print_r($query);exit;
     $recordsTotal = $query->num_rows();
     $query->free_result();
     return array("draw" => intval($request['draw']), "recordsTotal" => intval($recordsTotal), "recordsFiltered" => intval($recordsFiltered), "data" => SSP::data_output($columns, $data));
 }
开发者ID:niravpatel2008,项目名称:yummy-wookie,代码行数:53,代码来源:datatable_helper.php


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