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


PHP SSP::pluckAs方法代码示例

本文整理汇总了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));
 }
开发者ID:agungsb,项目名称:sid,代码行数:37,代码来源:ssp_class.php


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