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


PHP BP_Activity_Activity::get_in_operator_sql方法代码示例

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


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

示例1: get_filter_sql

 function get_filter_sql($filter_array)
 {
     global $nxtdb;
     if (!empty($filter_array['user_id'])) {
         $user_sql = BP_Activity_Activity::get_in_operator_sql('a.user_id', $filter_array['user_id']);
         if (!empty($user_sql)) {
             $filter_sql[] = $user_sql;
         }
     }
     if (!empty($filter_array['object'])) {
         $object_sql = BP_Activity_Activity::get_in_operator_sql('a.component', $filter_array['object']);
         if (!empty($object_sql)) {
             $filter_sql[] = $object_sql;
         }
     }
     if (!empty($filter_array['action'])) {
         $action_sql = BP_Activity_Activity::get_in_operator_sql('a.type', $filter_array['action']);
         if (!empty($action_sql)) {
             $filter_sql[] = $action_sql;
         }
     }
     if (!empty($filter_array['primary_id'])) {
         $pid_sql = BP_Activity_Activity::get_in_operator_sql('a.item_id', $filter_array['primary_id']);
         if (!empty($pid_sql)) {
             $filter_sql[] = $pid_sql;
         }
     }
     if (!empty($filter_array['secondary_id'])) {
         $sid_sql = BP_Activity_Activity::get_in_operator_sql('a.secondary_item_id', $filter_array['secondary_id']);
         if (!empty($sid_sql)) {
             $filter_sql[] = $sid_sql;
         }
     }
     if (empty($filter_sql)) {
         return false;
     }
     return join(' AND ', $filter_sql);
 }
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:38,代码来源:bp-activity-classes.php

示例2: get_sql_for_clause

 /**
  * Generate WHERE clauses for a first-order clause.
  *
  * @since BuddyPress (2.2.0)
  * @access protected
  *
  * @param  array $clause       Array of arguments belonging to the clause.
  * @param  array $parent_query Parent query to which the clause belongs.
  * @return array {
  *     @type array $where Array of subclauses for the WHERE statement.
  *     @type array $join  Empty array. Not used.
  * }
  */
 protected function get_sql_for_clause($clause, $parent_query)
 {
     global $wpdb;
     $sql_chunks = array('where' => array(), 'join' => array());
     $column = isset($clause['column']) ? $this->validate_column($clause['column']) : '';
     $value = isset($clause['value']) ? $clause['value'] : '';
     if (empty($column) || !isset($clause['value'])) {
         return $sql_chunks;
     }
     if (isset($clause['compare'])) {
         $clause['compare'] = strtoupper($clause['compare']);
     } else {
         $clause['compare'] = isset($clause['value']) && is_array($clause['value']) ? 'IN' : '=';
     }
     // default 'compare' to '=' if no valid operator is found
     if (!in_array($clause['compare'], array('=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN', 'REGEXP', 'NOT REGEXP', 'RLIKE'))) {
         $clause['compare'] = '=';
     }
     $compare = $clause['compare'];
     $alias = !empty($this->table_alias) ? "{$this->table_alias}." : '';
     // Next, Build the WHERE clause.
     $where = '';
     // value.
     if (isset($clause['value'])) {
         if (in_array($compare, array('IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'))) {
             if (!is_array($value)) {
                 $value = preg_split('/[,\\s]+/', $value);
             }
         }
         // tinyint
         if (!empty($column) && true === in_array($column, array('hide_sitewide', 'is_spam'))) {
             $sql_chunks['where'][] = $wpdb->prepare("{$alias}{$column} = %d", $value);
         } else {
             switch ($compare) {
                 // IN uses different syntax
                 case 'IN':
                 case 'NOT IN':
                     $in_sql = BP_Activity_Activity::get_in_operator_sql("{$alias}{$column}", $value);
                     // 'NOT IN' operator is as easy as a string replace!
                     if ('NOT IN' === $compare) {
                         $in_sql = str_replace('IN', 'NOT IN', $in_sql);
                     }
                     $sql_chunks['where'][] = $in_sql;
                     break;
                 case 'BETWEEN':
                 case 'NOT BETWEEN':
                     $value = array_slice($value, 0, 2);
                     $where = $wpdb->prepare('%s AND %s', $value);
                     break;
                 case 'LIKE':
                 case 'NOT LIKE':
                     $value = '%' . bp_esc_like($value) . '%';
                     $where = $wpdb->prepare('%s', $value);
                     break;
                 default:
                     $where = $wpdb->prepare('%s', $value);
                     break;
             }
         }
         if ($where) {
             $sql_chunks['where'][] = "{$alias}{$column} {$compare} {$where}";
         }
     }
     /*
      * Multiple WHERE clauses should be joined in parentheses.
      */
     if (1 < count($sql_chunks['where'])) {
         $sql_chunks['where'] = array('( ' . implode(' AND ', $sql_chunks['where']) . ' )');
     }
     return $sql_chunks;
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:84,代码来源:bp-activity-classes.php

示例3: get_filter_sql

 /**
  * Create filter SQL clauses.
  *
  * @since 1.5.0
  *
  * @param array $filter_array {
  *     Fields and values to filter by.
  *
  *     @type array|string|int $user_id User ID(s).
  *     @type array|string     $object       Corresponds to the 'component'
  *                                          column in the database.
  *     @type array|string     $action       Corresponds to the 'type' column
  *                                          in the database.
  *     @type array|string|int $primary_id   Corresponds to the 'item_id'
  *                                          column in the database.
  *     @type array|string|int $secondary_id Corresponds to the
  *                                          'secondary_item_id' column in the database.
  *     @type int              $offset       Return only those items with an ID greater
  *                                          than the offset value.
  *     @type string           $since        Return only those items that have a
  *                                          date_recorded value greater than a
  *                                          given MySQL-formatted date.
  * }
  * @return string The filter clause, for use in a SQL query.
  */
 public static function get_filter_sql($filter_array)
 {
     $filter_sql = array();
     if (!empty($filter_array['user_id'])) {
         $user_sql = BP_Activity_Activity::get_in_operator_sql('a.user_id', $filter_array['user_id']);
         if (!empty($user_sql)) {
             $filter_sql[] = $user_sql;
         }
     }
     if (!empty($filter_array['object'])) {
         $object_sql = BP_Activity_Activity::get_in_operator_sql('a.component', $filter_array['object']);
         if (!empty($object_sql)) {
             $filter_sql[] = $object_sql;
         }
     }
     if (!empty($filter_array['action'])) {
         $action_sql = BP_Activity_Activity::get_in_operator_sql('a.type', $filter_array['action']);
         if (!empty($action_sql)) {
             $filter_sql[] = $action_sql;
         }
     }
     if (!empty($filter_array['primary_id'])) {
         $pid_sql = BP_Activity_Activity::get_in_operator_sql('a.item_id', $filter_array['primary_id']);
         if (!empty($pid_sql)) {
             $filter_sql[] = $pid_sql;
         }
     }
     if (!empty($filter_array['secondary_id'])) {
         $sid_sql = BP_Activity_Activity::get_in_operator_sql('a.secondary_item_id', $filter_array['secondary_id']);
         if (!empty($sid_sql)) {
             $filter_sql[] = $sid_sql;
         }
     }
     if (!empty($filter_array['offset'])) {
         $sid_sql = absint($filter_array['offset']);
         $filter_sql[] = "a.id >= {$sid_sql}";
     }
     if (!empty($filter_array['since'])) {
         // Validate that this is a proper Y-m-d H:i:s date.
         // Trick: parse to UNIX date then translate back.
         $translated_date = date('Y-m-d H:i:s', strtotime($filter_array['since']));
         if ($translated_date === $filter_array['since']) {
             $filter_sql[] = "a.date_recorded > '{$translated_date}'";
         }
     }
     if (empty($filter_sql)) {
         return false;
     }
     return join(' AND ', $filter_sql);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:75,代码来源:class-bp-activity-activity.php

示例4: get_filter_sql

 /**
  * Create filter SQL clauses.
  *
  * @since BuddyPress (1.5.0)
  *
  * @param array $filter_array {
  *     Fields and values to filter by.
  *     @type array|string|id $user_id User ID(s).
  *     @type array|string $object Corresponds to the 'component'
  *           column in the database.
  *     @type array|string $action Corresponds to the 'type' column
  *           in the database.
  *     @type array|string|int $primary_id Corresponds to the 'item_id'
  *           column in the database.
  *     @type array|string|int $secondary_id Corresponds to the
  *           'secondary_item_id' column in the database.
  *     @type int $offset Return only those items with an ID greater
  *           than the offset value.
  *     @type string $since Return only those items that have a
  *           date_recorded value greater than a given MySQL-formatted
  *           date.
  * }
  * @return string The filter clause, for use in a SQL query.
  */
 public static function get_filter_sql($filter_array)
 {
     $filter_sql = array();
     if (!empty($filter_array['user_id'])) {
         global $wpdb;
         $user_sql = BP_Activity_Activity::get_in_operator_sql('a.user_id', $filter_array['user_id']);
         // START Also include @Mentions in User Stream
         $search_terms = '@' . bp_core_get_username($filter_array['user_id']);
         $user_sql .= "OR ( a.content LIKE '%%" . $wpdb->esc_like($search_terms) . "%%' )";
         // END Also include @Mentions in User Stream
         if (!empty($user_sql)) {
             $filter_sql[] = $user_sql;
         }
     }
     if (!empty($filter_array['object'])) {
         $object_sql = BP_Activity_Activity::get_in_operator_sql('a.component', $filter_array['object']);
         if (!empty($object_sql)) {
             $filter_sql[] = $object_sql;
         }
     }
     if (!empty($filter_array['action'])) {
         $action_sql = BP_Activity_Activity::get_in_operator_sql('a.type', $filter_array['action']);
         if (!empty($action_sql)) {
             $filter_sql[] = $action_sql;
         }
     }
     if (!empty($filter_array['primary_id'])) {
         $pid_sql = BP_Activity_Activity::get_in_operator_sql('a.item_id', $filter_array['primary_id']);
         if (!empty($pid_sql)) {
             $filter_sql[] = $pid_sql;
         }
     }
     if (!empty($filter_array['secondary_id'])) {
         $sid_sql = BP_Activity_Activity::get_in_operator_sql('a.secondary_item_id', $filter_array['secondary_id']);
         if (!empty($sid_sql)) {
             $filter_sql[] = $sid_sql;
         }
     }
     if (!empty($filter_array['offset'])) {
         $sid_sql = absint($filter_array['offset']);
         $filter_sql[] = "a.id >= {$sid_sql}";
     }
     if (!empty($filter_array['since'])) {
         // Validate that this is a proper Y-m-d H:i:s date
         // Trick: parse to UNIX date then translate back
         $translated_date = date('Y-m-d H:i:s', strtotime($filter_array['since']));
         if ($translated_date === $filter_array['since']) {
             $filter_sql[] = "a.date_recorded > '{$translated_date}'";
         }
     }
     if (empty($filter_sql)) {
         return false;
     }
     return join(' AND ', $filter_sql);
 }
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:79,代码来源:bp-activity-classes.php


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