本文整理汇总了PHP中SSP::pluckAs方法的典型用法代码示例。如果您正苦于以下问题:PHP SSP::pluckAs方法的具体用法?PHP SSP::pluckAs怎么用?PHP SSP::pluckAs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SSP
的用法示例。
在下文中一共展示了SSP::pluckAs方法的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, $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));
}