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


PHP EM_Object::build_sql_conditions方法代码示例

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


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

示例1: build_sql_conditions

 public static function build_sql_conditions($args = array())
 {
     self::$context = EM_POST_TYPE_EVENT;
     $conditions = parent::build_sql_conditions($args);
     if (!empty($args['search'])) {
         $like_search = array('event_name', EM_EVENTS_TABLE . '.post_content', 'location_name', 'location_address', 'location_town', 'location_postcode', 'location_state', 'location_country', 'location_region');
         $conditions['search'] = "(" . implode(" LIKE '%{$args['search']}%' OR ", $like_search) . "  LIKE '%{$args['search']}%')";
     }
     $conditions['status'] = "(`event_status` >= 0 )";
     //shows pending & published if not defined
     if (array_key_exists('status', $args)) {
         if (is_numeric($args['status'])) {
             $conditions['status'] = "(`event_status`={$args['status']})";
             //pending or published
         } elseif ($args['status'] == 'pending') {
             $conditions['status'] = "(`event_status`=0)";
             //pending
         } elseif ($args['status'] == 'publish') {
             $conditions['status'] = "(`event_status`=1)";
             //published
         } elseif ($args['status'] === null || $args['status'] == 'draft') {
             $conditions['status'] = "(`event_status` IS NULL )";
             //show draft items
         } elseif ($args['status'] == 'trash') {
             $conditions['status'] = "(`event_status` = -1 )";
             //show trashed items
         } elseif ($args['status'] == 'all') {
             $conditions['status'] = "(`event_status` >= 0 OR `event_status` IS NULL)";
             //search all statuses that aren't trashed
         } elseif ($args['status'] == 'everything') {
             unset($conditions['status']);
             //search all statuses
         }
     }
     //private events
     if (empty($args['private'])) {
         $conditions['private'] = "(`event_private`=0)";
     } elseif (!empty($args['private_only'])) {
         $conditions['private_only'] = "(`event_private`=1)";
     }
     if (EM_MS_GLOBAL && !empty($args['blog'])) {
         if (is_numeric($args['blog'])) {
             if (is_main_site($args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id={$args['blog']} OR " . EM_EVENTS_TABLE . ".blog_id IS NULL)";
             } else {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id={$args['blog']})";
             }
         } else {
             if (!is_array($args['blog']) && preg_match('/^([\\-0-9],?)+$/', $args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id IN ({$args['blog']}) )";
             } elseif (is_array($args['blog']) && self::array_is_numeric($args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id IN (" . implode(',', $args['blog']) . ") )";
             }
         }
     }
     if ($args['bookings'] === 'user' && is_user_logged_in()) {
         //get bookings of user
         $EM_Person = new EM_Person(get_current_user_id());
         $booking_ids = $EM_Person->get_bookings(true);
         if (count($booking_ids) > 0) {
             $conditions['bookings'] = "(event_id IN (SELECT event_id FROM " . EM_BOOKINGS_TABLE . " WHERE booking_id IN (" . implode(',', $booking_ids) . ")))";
         } else {
             $conditions['bookings'] = "(event_id = 0)";
         }
     }
     //post search
     if (!empty($args['post_id'])) {
         if (is_array($args['post_id'])) {
             $conditions['post_id'] = "(" . EM_EVENTS_TABLE . ".post_id IN (" . implode(',', $args['post_id']) . "))";
         } else {
             $conditions['post_id'] = "(" . EM_EVENTS_TABLE . ".post_id={$args['post_id']})";
         }
     }
     return apply_filters('em_events_build_sql_conditions', $conditions, $args);
 }
开发者ID:mpaskew,项目名称:isc-dev,代码行数:75,代码来源:em-events.php

示例2: array

 function build_sql_conditions($args = array())
 {
     $conditions = apply_filters('em_bookings_build_sql_conditions', parent::build_sql_conditions($args), $args);
     if (is_numeric($args['status'])) {
         $conditions['status'] = 'booking_status=' . $args['status'];
     } elseif (is_array($args['status']) && count($args['status']) > 0) {
         $conditions['status'] = 'booking_status IN (' . implode(',', $args['status']) . ')';
     } elseif (!is_array($args['status']) && preg_match('/^([0-9],?)+$/', $args['status'])) {
         $conditions['status'] = 'booking_status IN (' . $args['status'] . ')';
     }
     if (is_numeric($args['person']) && current_user_can('manage_others_bookings')) {
         $conditions['person'] = EM_BOOKINGS_TABLE . '.person_id=' . $args['person'];
     }
     if (EM_MS_GLOBAL && !empty($args['blog']) && is_numeric($args['blog'])) {
         if (is_main_site($args['blog'])) {
             $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id={$args['blog']} OR " . EM_EVENTS_TABLE . ".blog_id IS NULL)";
         } else {
             $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id={$args['blog']})";
         }
     }
     if (is_numeric($args['ticket_id'])) {
         $EM_Ticket = new EM_Ticket($args['ticket_id']);
         if ($EM_Ticket->can_manage()) {
             $conditions['ticket'] = EM_BOOKINGS_TABLE . '.booking_id IN (SELECT booking_id FROM ' . EM_TICKETS_BOOKINGS_TABLE . " WHERE ticket_id='{$args['ticket_id']}')";
         }
     }
     return apply_filters('em_bookings_build_sql_conditions', $conditions, $args);
 }
开发者ID:hscale,项目名称:webento,代码行数:28,代码来源:em-bookings.php

示例3: build_sql_conditions

 /**
  * Builds an array of SQL query conditions based on regularly used arguments
  * @param array $args
  * @return array
  */
 public static function build_sql_conditions($args = array(), $count = false)
 {
     self::$context = EM_POST_TYPE_LOCATION;
     global $wpdb;
     $events_table = EM_EVENTS_TABLE;
     $locations_table = EM_LOCATIONS_TABLE;
     $conditions = parent::build_sql_conditions($args);
     //search locations
     if (!empty($args['search'])) {
         $like_search = array($locations_table . '.post_content', 'location_name', 'location_address', 'location_town', 'location_postcode', 'location_state', 'location_region', 'location_country');
         $conditions['search'] = "(" . implode(" LIKE '%{$args['search']}%' OR ", $like_search) . "  LIKE '%{$args['search']}%')";
     }
     //eventful locations
     if (true == $args['eventful']) {
         $conditions['eventful'] = "{$events_table}.event_id IS NOT NULL AND event_status=1";
     } elseif (true == $args['eventless']) {
         $conditions['eventless'] = "{$events_table}.event_id IS NULL";
         if (!empty($conditions['scope'])) {
             unset($conditions['scope']);
         }
         //scope condition would render all queries return no results
     }
     //owner lookup
     if (!empty($args['owner']) && is_numeric($args['owner'])) {
         $conditions['owner'] = "location_owner=" . $args['owner'];
     } elseif (!empty($args['owner']) && $args['owner'] == 'me' && is_user_logged_in()) {
         $conditions['owner'] = 'location_owner=' . get_current_user_id();
     } elseif (self::array_is_numeric($args['owner'])) {
         $conditions['owner'] = 'location_owner IN (' . implode(',', $args['owner']) . ')';
     }
     //blog id in events table
     if (EM_MS_GLOBAL && !empty($args['blog'])) {
         if (is_numeric($args['blog'])) {
             if (is_main_site($args['blog'])) {
                 $conditions['blog'] = "(" . $locations_table . ".blog_id={$args['blog']} OR " . $locations_table . ".blog_id IS NULL)";
             } else {
                 $conditions['blog'] = "(" . $locations_table . ".blog_id={$args['blog']})";
             }
         } else {
             if (!is_array($args['blog']) && preg_match('/^([\\-0-9],?)+$/', $args['blog'])) {
                 $conditions['blog'] = "(" . $locations_table . ".blog_id IN ({$args['blog']}) )";
             } elseif (is_array($args['blog']) && self::array_is_numeric($args['blog'])) {
                 $conditions['blog'] = "(" . $locations_table . ".blog_id IN (" . implode(',', $args['blog']) . ") )";
             }
         }
     }
     //status
     $conditions['status'] = "(`location_status` >= 0)";
     //pending and published if status is not explicitly defined (Default is 1)
     if (array_key_exists('status', $args)) {
         if (is_numeric($args['status'])) {
             $conditions['status'] = "(`location_status`={$args['status']} )";
             //trash (-1), pending, (0) or published (1)
         } elseif ($args['status'] == 'pending') {
             $conditions['status'] = "(`location_status`=0)";
             //pending
         } elseif ($args['status'] == 'publish') {
             $conditions['status'] = "(`location_status`=1)";
             //published
         } elseif ($args['status'] === null || $args['status'] == 'draft') {
             $conditions['status'] = "(`location_status` IS NULL )";
             //show draft items
         } elseif ($args['status'] == 'trash') {
             $conditions['status'] = "(`location_status` = -1 )";
             //show trashed items
         } elseif ($args['status'] == 'all') {
             $conditions['status'] = "(`location_status` >= 0 OR `location_status` IS NULL)";
             //search all statuses that aren't trashed
         } elseif ($args['status'] == 'everything') {
             unset($conditions['status']);
             //search all statuses
         }
     }
     //private locations
     if (empty($args['private'])) {
         $conditions['private'] = "(`location_private`=0 AND `event_private`=0)";
     } elseif (!empty($args['private_only'])) {
         $conditions['private_only'] = "(`location_private`=1 OR `event_private`=1)";
     }
     //post search
     if (!empty($args['post_id'])) {
         if (is_array($args['post_id'])) {
             $conditions['post_id'] = "({$locations_table}.post_id IN (" . implode(',', $args['post_id']) . "))";
         } else {
             $conditions['post_id'] = "({$locations_table}.post_id={$args['post_id']})";
         }
     }
     return apply_filters('em_locations_build_sql_conditions', $conditions, $args);
 }
开发者ID:KhanMaytok,项目名称:events-manager,代码行数:94,代码来源:em-locations.php

示例4: array

 function build_sql_conditions($args = array())
 {
     $conditions = parent::build_sql_conditions($args);
     if (!empty($args['search'])) {
         $like_search = array('event_name', EM_EVENTS_TABLE . '.post_content', 'location_name', 'location_address', 'location_town', 'location_postcode', 'location_state', 'location_country');
         $conditions['search'] = "(" . implode(" LIKE '%{$args['search']}%' OR ", $like_search) . "  LIKE '%{$args['search']}%')";
     }
     if (array_key_exists('status', $args) && is_numeric($args['status'])) {
         $null = $args['status'] == 0 ? ' OR `event_status` = 0' : '';
         $conditions['status'] = "(`event_status`={$args['status']}{$null} )";
     } elseif (empty($args['status']) || $args['status'] != 'all') {
         $conditions['status'] = "(`event_status` IS NOT NULL )";
         //by default, we don't ever show deleted items
     }
     //private events
     if (empty($args['private'])) {
         $conditions['private'] = "(`event_private`=0)";
     } elseif (!empty($args['private_only'])) {
         $conditions['private_only'] = "(`event_private`=1)";
     }
     if (EM_MS_GLOBAL && !empty($args['blog'])) {
         if (is_numeric($args['blog'])) {
             if (is_main_site($args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id={$args['blog']} OR " . EM_EVENTS_TABLE . ".blog_id IS NULL)";
             } else {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id={$args['blog']})";
             }
         } else {
             if (!is_array($args['blog']) && preg_match('/^([\\-0-9],?)+$/', $args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id IN ({$args['blog']}) )";
             } elseif (is_array($args['blog']) && $this->array_is_numeric($args['blog'])) {
                 $conditions['blog'] = "(" . EM_EVENTS_TABLE . ".blog_id IN (" . implode(',', $args['blog']) . ") )";
             }
         }
     }
     if ($args['bookings'] === 'user' && is_user_logged_in()) {
         //get bookings of user
         $EM_Person = new EM_Person(get_current_user_id());
         $booking_ids = $EM_Person->get_bookings(true);
         if (count($booking_ids) > 0) {
             $conditions['bookings'] = "(event_id IN (SELECT event_id FROM " . EM_BOOKINGS_TABLE . " WHERE booking_id IN (" . implode(',', $booking_ids) . ")))";
         } else {
             $conditions['bookings'] = "(event_id = 0)";
         }
     }
     //post search
     if (!empty($args['post_id'])) {
         if (is_array($args['post_id'])) {
             $conditions['post_id'] = "(" . EM_EVENTS_TABLE . ".post_id IN (" . implode(',', $args['post_id']) . "))";
         } else {
             $conditions['post_id'] = "(" . EM_EVENTS_TABLE . ".post_id={$args['post_id']})";
         }
     }
     return apply_filters('em_events_build_sql_conditions', $conditions, $args);
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:55,代码来源:em-events.php

示例5: array

 /**
  * Builds an array of SQL query conditions based on regularly used arguments
  * @param array $args
  * @return array
  */
 function build_sql_conditions($args = array(), $count = false)
 {
     global $wpdb;
     $events_table = EM_EVENTS_TABLE;
     $locations_table = EM_LOCATIONS_TABLE;
     $conditions = parent::build_sql_conditions($args);
     //eventful locations
     if (true == $args['eventful']) {
         $conditions['eventful'] = "{$events_table}.event_id IS NOT NULL";
     } elseif (true == $args['eventless']) {
         $conditions['eventless'] = "{$events_table}.event_id IS NULL";
     }
     //owner lookup
     if (!empty($args['owner']) && is_numeric($args['owner'])) {
         $conditions['owner'] = "location_owner=" . $args['owner'];
     } elseif (!empty($args['owner']) && $args['owner'] == 'me' && is_user_logged_in()) {
         $conditions['owner'] = 'location_owner=' . get_current_user_id();
     }
     //blog id in events table
     if (EM_MS_GLOBAL && !empty($args['blog'])) {
         if (is_numeric($args['blog'])) {
             if (is_main_site($args['blog'])) {
                 $conditions['blog'] = "(" . $locations_table . ".blog_id={$args['blog']} OR " . $locations_table . ".blog_id IS NULL)";
             } else {
                 $conditions['blog'] = "(" . $locations_table . ".blog_id={$args['blog']})";
             }
         } else {
             if (!is_array($args['blog']) && preg_match('/^([\\-0-9],?)+$/', $args['blog'])) {
                 $conditions['blog'] = "(" . $locations_table . ".blog_id IN ({$args['blog']}) )";
             } elseif (is_array($args['blog']) && $this->array_is_numeric($args['blog'])) {
                 $conditions['blog'] = "(" . $locations_table . ".blog_id IN (" . implode(',', $args['blog']) . ") )";
             }
         }
     }
     //status
     if (array_key_exists('status', $args) && is_numeric($args['status'])) {
         $null = $args['status'] == 0 ? ' OR `location_status` = 0' : '';
         $conditions['status'] = "(`location_status`={$args['status']}{$null} )";
     } else {
         $conditions['status'] = "(`location_status` IS NOT NULL)";
     }
     //private locations
     if (empty($args['private'])) {
         $conditions['private'] = "(`location_private`=0)";
     } elseif (!empty($args['private_only'])) {
         $conditions['private_only'] = "(`location_private`=1)";
     }
     //post search
     if (!empty($args['post_id'])) {
         if (is_array($args['post_id'])) {
             $conditions['post_id'] = "({$locations_table}.post_id IN (" . implode(',', $args['post_id']) . "))";
         } else {
             $conditions['post_id'] = "({$locations_table}.post_id={$args['post_id']})";
         }
     }
     return apply_filters('em_locations_build_sql_conditions', $conditions, $args);
 }
开发者ID:Blueprint-Marketing,项目名称:interoccupy.net,代码行数:62,代码来源:em-locations.php

示例6: array

 function build_sql_conditions($args = array())
 {
     $conditions = parent::build_sql_conditions($args);
     if (!empty($args['search'])) {
         $like_search = array('event_name', 'event_notes', 'location_name', 'location_address', 'location_town', 'location_postcode', 'location_state', 'location_country');
         $conditions['search'] = "(" . implode(" LIKE '%{$args['search']}%' OR ", $like_search) . "  LIKE '%{$args['search']}%')";
     }
     if (array_key_exists('status', $args) && is_numeric($args['status'])) {
         $conditions['status'] = "(`event_status`={$args['status']})";
     }
     if (is_multisite() && array_key_exists('blog', $args) && is_numeric($args['blog'])) {
         if (is_main_site($args['blog'])) {
             $conditions['blog'] = "(`blog_id`={$args['blog']} OR blog_id IS NULL)";
         } else {
             $conditions['blog'] = "(`blog_id`={$args['blog']})";
         }
     }
     return apply_filters('em_events_build_sql_conditions', $conditions, $args);
 }
开发者ID:hypenotic,项目名称:slowfood,代码行数:19,代码来源:em-events.php

示例7: array

 function build_sql_conditions($args = array())
 {
     $conditions = apply_filters('em_bookings_build_sql_conditions', parent::build_sql_conditions($args), $args);
     if (is_numeric($args['status'])) {
         $conditions['status'] = 'booking_status=' . $args['status'];
     }
     return apply_filters('em_bookings_build_sql_conditions', $conditions, $args);
 }
开发者ID:hypenotic,项目名称:slowfood,代码行数:8,代码来源:em-bookings.php

示例8: array

 /**
  * Builds an array of SQL query conditions based on regularly used arguments
  * @param array $args
  * @return array
  */
 function build_sql_conditions($args = array())
 {
     global $wpdb;
     $events_table = $wpdb->prefix . EM_EVENTS_TABLE;
     $locations_table = $wpdb->prefix . EM_LOCATIONS_TABLE;
     $conditions = parent::build_sql_conditions($args);
     //eventful locations
     if (true == $args['eventful']) {
         $conditions['eventful'] = "{$events_table}.event_id IS NOT NULL";
     } elseif (true == $args['eventless']) {
         $conditions['eventless'] = "{$events_table}.event_id IS NULL";
     }
     //owner lookup
     if (!empty($args['owner'])) {
         if (get_option('dbem_permissions_locations') < 1 && !em_verify_admin()) {
             $conditions['owner'] = "location_owner=" . get_current_user_id();
         }
     }
     return apply_filters('em_locations_build_sql_conditions', $conditions, $args);
 }
开发者ID:hypenotic,项目名称:slowfood,代码行数:25,代码来源:em-locations.php

示例9: array

 function build_sql_conditions($args = array())
 {
     global $wpdb;
     $events_table = EM_EVENTS_TABLE;
     $locations_table = EM_LOCATIONS_TABLE;
     $temp_conditions = parent::build_sql_conditions($args);
     $conditions = array();
     if (!empty($temp_conditions['category'])) {
         $conditions['category'] = $temp_conditions['category'];
     }
     return apply_filters('em_categories_build_sql_conditions', $conditions, $args);
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:12,代码来源:em-categories.php

示例10: array

 /**
  * Builds an array of SQL query conditions based on regularly used arguments
  * @param array $args
  * @return array
  */
 function build_sql_conditions($args = array())
 {
     global $wpdb;
     $events_table = EM_EVENTS_TABLE;
     $locations_table = EM_LOCATIONS_TABLE;
     $conditions = parent::build_sql_conditions($args);
     //eventful locations
     if (true == $args['eventful']) {
         $conditions['eventful'] = "{$events_table}.event_id IS NOT NULL";
     } elseif (true == $args['eventless']) {
         $conditions['eventless'] = "{$events_table}.event_id IS NULL";
     }
     //owner lookup
     if (!empty($args['owner'])) {
         $conditions['owner'] = "location_owner=" . $args['owner'];
     }
     //blog id in events table
     if (is_multisite() && array_key_exists('blog', $args) && is_numeric($args['blog'])) {
         if (is_main_site($args['blog'])) {
             $conditions['blog'] = "(`blog_id`={$args['blog']} OR blog_id IS NULL)";
         } else {
             $conditions['blog'] = "(`blog_id`={$args['blog']})";
         }
     }
     return apply_filters('em_locations_build_sql_conditions', $conditions, $args);
 }
开发者ID:hypenotic,项目名称:slowfood,代码行数:31,代码来源:em-locations.php

示例11: array

 function build_sql_conditions($args = array())
 {
     return apply_filters('em_events_build_sql_conditions', parent::build_sql_conditions($args), $args);
 }
开发者ID:hypenotic,项目名称:slowfood,代码行数:4,代码来源:em-events.php

示例12: array

 function build_sql_conditions($args = array())
 {
     $conditions = apply_filters('em_bookings_build_sql_conditions', parent::build_sql_conditions($args), $args);
     if (is_numeric($args['status'])) {
         $conditions['status'] = 'booking_status=' . $args['status'];
     } elseif (is_array($args['status']) && count($args['status']) > 0) {
         $conditions['status'] = 'booking_status IN (' . implode(',', $args['status']) . ')';
     } elseif (!is_array($args['status']) && preg_match('/^([0-9],?)+$/', $args['status'])) {
         $conditions['status'] = 'booking_status IN (' . $args['status'] . ')';
     }
     if (is_numeric($args['person']) && current_user_can('manage_others_bookings')) {
         $conditions['person'] = EM_BOOKINGS_TABLE . '.person_id=' . $args['person'];
     }
     return apply_filters('em_bookings_build_sql_conditions', $conditions, $args);
 }
开发者ID:rajankz,项目名称:webspace,代码行数:15,代码来源:em-bookings.php


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