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


PHP SSP::bind方法代码示例

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


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

示例1: filter

 /**
 * Searching / Filtering
 *
 * Construct the WHERE clause for server-side processing SQL query.
 *
 * NOTE this does not match the built-in DataTables filtering which does it
 * word by word on any field. It's possible to do here performance on large
 * databases would be very poor
 *
 *  @param  array $request Data sent to server by DataTables
 *  @param  array $columns Column information array
 *  @param  array $bindings Array of values for PDO bindings, used in the
 *    sql_exec() function
 *  @return string SQL where clause
 EDIT : added $mywhere functionality for passing initial filtering conditions
 */
 static function filter($request, $columns, &$bindings, $myWhere)
 {
     $globalSearch = array();
     $columnSearch = array();
     $dtColumns = SSP::pluck($columns, 'dt');
     if (isset($request['search']) && $request['search']['value'] != '') {
         $str = $request['search']['value'];
         for ($i = 0, $ien = count($request['columns']); $i < $ien; $i++) {
             $requestColumn = $request['columns'][$i];
             $columnIdx = array_search($requestColumn['data'], $dtColumns);
             $column = $columns[$columnIdx];
             if ($requestColumn['searchable'] == 'true') {
                 $binding = SSP::bind($bindings, '%' . $str . '%', PDO::PARAM_STR);
                 $globalSearch[] = "" . $column['db'] . " LIKE " . $binding;
             }
         }
     }
     // Individual column filtering
     for ($i = 0, $ien = count($request['columns']); $i < $ien; $i++) {
         $requestColumn = $request['columns'][$i];
         $columnIdx = array_search($requestColumn['data'], $dtColumns);
         $column = $columns[$columnIdx];
         $str = $requestColumn['search']['value'];
         if ($requestColumn['searchable'] == 'true' && $str != '') {
             $binding = SSP::bind($bindings, '%' . $str . '%', PDO::PARAM_STR);
             $columnSearch[] = "" . $column['db'] . " LIKE " . $binding;
         }
     }
     // Combine the filters into a single string
     $where = '';
     if (count($globalSearch)) {
         $where = '(' . implode(' OR ', $globalSearch) . ')';
     }
     if (count($columnSearch)) {
         $where = $where === '' ? implode(' AND ', $globalSearch) : $where . ' AND ' . implode(' AND ', $globalSearch);
     }
     if ($where !== '') {
         $where = 'WHERE ' . $where;
         // add my clause
         if ($myWhere !== '') {
             $where .= ' AND ' . $myWhere;
         }
     }
     if ($where == '' && $myWhere !== '') {
         // add my clause
         $where = 'WHERE ' . $myWhere;
     }
     return $where;
 }
开发者ID:agungsb,项目名称:sid,代码行数:65,代码来源:ssp_class.php

示例2: filter

 /**
  * Searching / Filtering
  *
  * Construct the WHERE clause for server-side processing SQL query.
  *
  * NOTE this does not match the built-in DataTables filtering which does it
  * word by word on any field. It's possible to do here performance on large
  * databases would be very poor
  *
  * @param  array $request Data sent to server by DataTables
  * @param  array $columns Column information array
  * @param  array $bindings Array of values for PDO bindings, used in the
  *    sql_exec() function
  * @return string SQL where clause
  */
 static function filter($request, $columns, &$bindings)
 {
     //log_message('error','$request '.$request);
     //echo($request);
     $globalSearch = array();
     $columnSearch = array();
     $dtColumns = SSP::pluck($columns, 'dt');
     if (isset($request['search']) && $request['search']['value'] != '') {
         $str = $request['search']['value'];
         for ($i = 0, $ien = count($request['columns']); $i < $ien; $i++) {
             $requestColumn = $request['columns'][$i];
             $columnIdx = array_search($requestColumn['data'], $dtColumns);
             $column = $columns[$columnIdx];
             if ($requestColumn['searchable'] == 'true') {
                 $binding = SSP::bind($bindings, '%' . $str . '%', PDO::PARAM_STR);
                 $globalSearch[] = "`" . $column['db'] . "` LIKE " . $binding;
             }
         }
     }
     // Individual column filtering
     for ($i = 0, $ien = count($request['columns']); $i < $ien; $i++) {
         $requestColumn = $request['columns'][$i];
         $columnIdx = array_search($requestColumn['data'], $dtColumns);
         $column = $columns[$columnIdx];
         $str = $requestColumn['search']['value'];
         if ($requestColumn['searchable'] == 'true' && $str != '') {
             $binding = SSP::bind($bindings, '%' . $str . '%', PDO::PARAM_STR);
             $columnSearch[] = "`" . $column['db'] . "` LIKE " . $binding;
         }
     }
     // Combine the filters into a single string
     $where = '';
     if (count($globalSearch)) {
         $where = '(' . implode(' OR ', $globalSearch) . ')';
     }
     if (count($columnSearch)) {
         $where = $where === '' ? implode(' AND ', $columnSearch) : $where . ' AND ' . implode(' AND ', $columnSearch);
     }
     if ($where !== '') {
         $where = 'WHERE ' . $where;
     }
     if (isset($request['tag'])) {
         if ($where !== '') {
             $where = $where . ' and tag in (' . $request['tag'] . ') ';
         } else {
             $where = 'WHERE tag in (' . $request['tag'] . ') ';
         }
     }
     return $where;
 }
开发者ID:wjyGamedev,项目名称:xuezhiweb,代码行数:65,代码来源:ssp.class.php


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