本文整理汇总了PHP中SSP::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP SSP::filter方法的具体用法?PHP SSP::filter怎么用?PHP SSP::filter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SSP
的用法示例。
在下文中一共展示了SSP::filter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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, $db, $table, $primaryKey, $columns, $myJoin, $myWhere)
{
$bindings = array();
//$db = SSP::sql_connect( $sql_details );
// Build the SQL query string from the request
$limit = SSP::limit($request, $columns);
$order = SSP::order($request, $columns);
$where = SSP::filter($request, $columns, $bindings, $myWhere);
// Main query to actually get the data
$data = SSP::sql_exec($db, $bindings, "SELECT SQL_CALC_FOUND_ROWS " . implode(", ", SSP::pluckAs($columns)) . "\n FROM {$table}\n {$myJoin}\n {$where}\n {$order}\n {$limit}");
// Data set length after filtering
$resFilterLength = SSP::sql_exec($db, "SELECT FOUND_ROWS()");
$recordsFiltered = $resFilterLength[0][0];
//add my initial where clause for correct results
$dataWhere = $myWhere !== '' ? 'WHERE ' . $myWhere : '';
// Total data set length
$resTotalLength = SSP::sql_exec($db, "SELECT COUNT({$primaryKey})\n FROM {$table}\n {$myJoin}\n {$dataWhere}");
$recordsTotal = $resTotalLength[0][0];
/*
* Output
*/
return array("draw" => intval($request['draw']), "recordsTotal" => intval($recordsTotal), "recordsFiltered" => intval($recordsFiltered), "data" => SSP::data_output($columns, $data));
}
示例2: 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
* @param array $joinQuery Join query String
* @param string $extraWhere Where query String
*
* @return array Server-side processing response array
*
*/
static function simple($conn, $request, $table, $primaryKey, $columns, $joinQuery = NULL, $extraWhere = '', $groupBy = '')
{
// static function simple ( $request, $sql_details, $table, $primaryKey, $columns,
// $joinQuery = NULL, $extraWhere = '', $groupBy = '') {
$bindings = array();
//$db = SSP::sql_connect( $sql_details );
// Build the SQL query string from the request
$limit = SSP::limit($request, $columns);
$order = SSP::order($request, $columns, $joinQuery);
$where = SSP::filter($request, $columns, $bindings, $joinQuery);
// IF Extra where set then set and prepare query
if ($extraWhere) {
$extraWhere = $where ? ' AND ' . $extraWhere : ' WHERE ' . $extraWhere;
}
$groupBy = $groupBy ? ' GROUP BY ' . $groupBy . ' ' : '';
// Main query to actually get the data
if ($joinQuery) {
$col = SSP::pluck($columns, 'db', $joinQuery);
$query = "SELECT SQL_CALC_FOUND_ROWS " . implode(", ", $col) . "\n {$joinQuery}\n {$where}\n {$extraWhere}\n {$groupBy}\n {$order}\n {$limit}";
} else {
$query = "SELECT SQL_CALC_FOUND_ROWS " . implode(", ", SSP::pluck($columns, 'db')) . "\n FROM {$table}\n {$where}\n {$extraWhere}\n {$groupBy}\n {$order}\n {$limit}";
}
$conn->Execute("SET NAMES 'utf8'");
$data = SSP::sql_exec($conn, $bindings, $query);
// Data set length after filtering
$resFilterLength = SSP::sql_exec($conn, "SELECT FOUND_ROWS() as cnt");
$recordsFiltered = $resFilterLength[0][cnt];
// Total data set length
$resTotalLength = SSP::sql_exec($conn, "SELECT COUNT({$primaryKey}) as cnt FROM {$table}");
$recordsTotal = $resTotalLength[0][cnt];
//file_put_contents('d:\query', $query);
//file_put_contents('d:\bindings', $bindings);
//file_put_contents('d:\11', varDump($resFilterLength));
//file_put_contents('d:\12', $recordsFiltered);
//file_put_contents('d:\data', varDump($data));
/*
* Output
*/
return array("draw" => intval($request['draw']), "recordsTotal" => intval($recordsTotal), "recordsFiltered" => intval($recordsFiltered), "data" => SSP::data_output($columns, $data, $joinQuery));
}
示例3: 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));
}
示例4: json_encode
$json['recordsTotal'] = $recordsFiltered;
$json['recordsFiltered'] = $recordsFiltered;
$json['data'] = SSP::data_output($columns, $data);
echo json_encode($json);
// $resTotalLength = SSP::sql_exec( $db, $bindings,
// "SELECT COUNT(`{$primaryKey}`)
// FROM `$table` ".
// $whereAllSql
// );
die;
$bindings = array();
//$db = self::db( $conn );
// Build the SQL query string from the request
$limit = SSP::limit($_GET, $columns);
$order = SSP::order($_GET, $columns);
$where = SSP::filter($_GET, $columns, $bindings);
// Main query to actually get the data
echo $where;
die;
$inputs = array();
foreach ($bindings as $value) {
$inputs[$value['key']] = $value['val'];
}
if (!empty($inputs)) {
$where = "WHERE (CONCAT(first_name,' ',middle_name,' ',last_name) LIKE :binding_0 OR `username` LIKE :binding_1 OR `email` LIKE :binding_2 OR `contact_no` LIKE :binding_3 OR `employee_no` LIKE :binding_4 OR `location` LIKE :binding_5 OR `title` LIKE :binding_6 OR `department` LIKE :binding_7 OR `id` LIKE :binding_8)";
}
if (empty($_GET['status']) || $_GET['status'] == 'All') {
$where = "is_deleted=0";
} else {
if ($_GET['status'] != "Deployed") {
if ($_GET['status'] == 'Deployable') {
示例5: 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, $sql_details, $table, $primaryKey, $columns) {
$bindings = array();
$db = SSP::sql_connect($sql_details);
// Build the SQL query string from the request
$limit = SSP::limit($request, $columns);
$order = SSP::order($request, $columns);
$where = SSP::filter($request, $columns, $bindings);
// Main query to actually get the data
$data = SSP::sql_exec($db, $bindings, "SELECT SQL_CALC_FOUND_ROWS `" . implode("`, `", SSP::pluck($columns, 'db')) . "`
FROM `$table`
$where
$order
$limit"
);
// Data set length after filtering
$resFilterLength = SSP::sql_exec($db, "SELECT FOUND_ROWS()"
);
$recordsFiltered = $resFilterLength[0][0];
// Total data set length
$resTotalLength = SSP::sql_exec($db, "SELECT COUNT(`{$primaryKey}`)
FROM `$table`"
);
$recordsTotal = $resTotalLength[0][0];
/*
* Output
*/
return array(
"draw" => intval($request['draw']),
"recordsTotal" => intval($recordsTotal),
"recordsFiltered" => intval($recordsFiltered),
"data" => SSP::data_output($columns, $data)
);
}
示例6: 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
* @param array $joinQuery Join query String
* @param string $extraWhere Where query String
*
* @return array Server-side processing response array
*
*/
static function simple($request, $sql_details, $table, $primaryKey, $columns, $joinQuery = NULL, $extraWhere = '', $groupBy = '')
{
$bindings = array();
$db = SSP::sql_connect($sql_details);
// Build the SQL query string from the request
$limit = SSP::limit($request, $columns);
$order = SSP::order($request, $columns, $joinQuery);
$where = SSP::filter($request, $columns, $bindings, $joinQuery);
// IF Extra where set then set and prepare query
if ($extraWhere) {
$extraWhere = $where ? ' AND ' . $extraWhere : ' WHERE ' . $extraWhere;
}
$groupBy = $groupBy ? ' GROUP BY ' . $groupBy . ' ' : '';
// Main query to actually get the data
if ($joinQuery) {
$col = SSP::pluck($columns, 'db', $joinQuery);
$query = "SELECT SQL_CALC_FOUND_ROWS " . implode(", ", $col) . "\n\t\t\t {$joinQuery}\n\t\t\t {$where}\n\t\t\t {$extraWhere}\n {$groupBy}\n\t\t\t {$order}\n\t\t\t {$limit}";
} else {
$query = "SELECT SQL_CALC_FOUND_ROWS `" . implode("`, `", SSP::pluck($columns, 'db')) . "`\n\t\t\t FROM `{$table}`\n\t\t\t {$where}\n\t\t\t {$extraWhere}\n\t\t\t {$groupBy}\n {$order}\n\t\t\t {$limit}";
}
$data = SSP::sql_exec($db, $bindings, $query);
// Data set length after filtering
$resFilterLength = SSP::sql_exec($db, "SELECT FOUND_ROWS()");
$recordsFiltered = $resFilterLength[0][0];
// Total data set length
$count_request = "SELECT COUNT(`{$primaryKey}`)";
if ($joinQuery) {
$count_request .= $joinQuery;
} else {
$count_request .= "FROM `{$table}`";
}
$resTotalLength = SSP::sql_exec($db, $count_request);
$recordsTotal = $resTotalLength[0][0];
/*
* Output
*/
return array("draw" => intval($request['draw']), "recordsTotal" => intval($recordsTotal), "recordsFiltered" => intval($recordsFiltered), "data" => SSP::data_output($columns, $data, $joinQuery));
}