本文整理汇总了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));
}