• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP like_escape函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中like_escape函数的典型用法代码示例。如果您正苦于以下问题:PHP like_escape函数的具体用法?PHP like_escape怎么用?PHP like_escape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_sql

 function get_sql()
 {
     global $wpdb;
     if (empty($this->queries)) {
         return array('join' => '', 'where' => '');
     }
     $context_table = MainWP_WP_Stream_DB::$table_context;
     $main_table = MainWP_WP_Stream_DB::$table;
     $meta_id_column = 'meta_id';
     $join = array();
     $where = array();
     $queries = $this->queries;
     $meta_query = new WP_Meta_Query();
     foreach ($queries as $i => $query) {
         foreach ($query as $key => $args) {
             $type = $meta_query->get_cast_for_type(isset($args['type']) ? $args['type'] : '');
             $value = isset($args['value']) ? $args['value'] : null;
             // Allow 'context' => array('val1', 'val2') as well
             if (is_null($value)) {
                 $args = array('value' => $args);
                 $value = $args['value'];
             }
             if (isset($args['compare'])) {
                 $compare = strtoupper($args['compare']);
             } else {
                 $compare = is_array($value) ? 'IN' : '=';
             }
             $operators = array('=', '!=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'REGEXP', 'NOT REGEXP', 'RLIKE');
             if (!in_array($compare, $operators)) {
                 $compare = '=';
             }
             if ('IN' === substr($compare, -2)) {
                 if (!is_array($value)) {
                     $value = preg_split('/[,\\s]+/', $value);
                 }
                 $compare_string = '(' . substr(str_repeat(',%s', count($value)), 1) . ')';
             } elseif ('LIKE' === substr($compare, -4)) {
                 $value = '%' . like_escape($value) . '%';
                 $compare_string = '%s';
             } else {
                 $compare_string = '%s';
             }
             if (!empty($where[$i])) {
                 $where[$i] .= ' AND ';
             } else {
                 $where[$i] = '';
             }
             $where[$i] = ' (' . $where[$i] . $wpdb->prepare("CAST({$context_table}.{$key} AS {$type}) {$compare} {$compare_string})", $value);
         }
     }
     $where = array_filter($where);
     if (empty($where)) {
         $where = '';
     } else {
         $where = ' AND (' . implode("\n{$this->relation} ", $where) . ' )';
     }
     $join = implode("\n", $join);
     return apply_filters_ref_array('get_context_sql', array(compact('join', 'where'), $this->queries));
 }
开发者ID:HasClass0,项目名称:mainwp-child-reports,代码行数:59,代码来源:context-query.php


示例2: prepare_items

 function prepare_items()
 {
     global $frmdb, $wpdb, $per_page, $frm_settings, $frm_form, $frm_app_helper;
     $paged = $this->get_pagenum();
     $default_orderby = 'name';
     $default_order = 'ASC';
     $orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : $default_orderby;
     $order = isset($_REQUEST['order']) ? $_REQUEST['order'] : $default_order;
     $page = $this->get_pagenum();
     $default_count = empty($this->page_name) ? 20 : 10;
     $per_page = $this->get_items_per_page('formidable_page_formidable' . str_replace('-', '_', $this->page_name) . '_per_page', $default_count);
     $start = isset($_REQUEST['start']) ? $_REQUEST['start'] : ($page - 1) * $per_page;
     $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
     $fid = isset($_REQUEST['fid']) ? $_REQUEST['fid'] : '';
     if ($s != '') {
         $s = stripslashes($s);
         preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
         $search_terms = array_map('_search_terms_tidy', $matches[0]);
     }
     $s_query = " (status is NULL OR status = '' OR status = 'published') AND default_template=0 AND is_template = " . (int) $this->params['template'];
     if ($s != '') {
         foreach ((array) $search_terms as $term) {
             $term = esc_sql(like_escape($term));
             if (!empty($s_query)) {
                 $s_query .= " AND";
             }
             $s_query .= " (name like '%{$term}%' OR description like '%{$term}%' OR created_at like '%{$term}%')";
             unset($term);
         }
     }
     $this->items = $frm_form->getAll($s_query, " ORDER BY {$orderby} {$order}", " LIMIT {$start}, {$per_page}", true, false);
     $total_items = $frm_app_helper->getRecordCount($s_query, $this->table_name);
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page));
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:34,代码来源:FrmListHelper.php


示例3: __format_search

 protected function __format_search()
 {
     $this->s_query = explode("-", $this->options['s_query']);
     $this->s_query = implode(" ", $this->s_query);
     $this->s_query = '%' . like_escape(esc_sql($this->s_query)) . '%';
     // Thanks Manny Fleurmond
 }
开发者ID:jamiemorganward,项目名称:aotearoa-search,代码行数:7,代码来源:customsearch.php


示例4: sf_acf_check_args_for_checkboxes

function sf_acf_check_args_for_checkboxes($args)
{
    if (!isset($args['meta_query'])) {
        return $args;
    }
    $acf_fields = array();
    foreach ($args['meta_query'] as $key => $val) {
        $is_checkbox = sf_acf_is_checkbox(array('add_this' => false, 'meta_key' => $val['key']));
        if ($is_checkbox['add_this']) {
            $acf_fields[] = $val;
            unset($args['meta_query'][$key]);
        }
    }
    $where_meta = array();
    foreach ($acf_fields as $field) {
        if (!is_array($field['value'])) {
            $where_meta[$field['key']][] = 's:' . strlen($field['value']) . ':"' . $field['value'] . '";';
        } else {
            foreach ($field['value'] as $fv) {
                $where_meta[$field['key']][] = 's:' . strlen($fv) . ':"' . esc_sql(like_escape($fv)) . '";';
            }
        }
    }
    if (count($where_meta) > 0) {
        add_filter('posts_join_paged', 'sf_acf_checkbox_filter_join', 10, 2);
        add_filter('posts_where', 'sf_acf_checkbox_filter_where', 10, 2);
        add_filter('posts_groupby', 'sf_groupby');
        $args['sf-acfcheckbox-meta'] = $where_meta;
    }
    return $args;
}
开发者ID:Juni4567,项目名称:meritscholarship,代码行数:31,代码来源:acf-checkboxes.php


示例5: leadout_check_merged_contact

/**
 * Check if the cookied hashkey has been merged with another contact. If it is, set visitor's cookie to new hashkey
 *
 * @echo	Hashkey from a merged_hashkeys row, FALSE if hashkey does not exist in a merged_hashkeys row
 */
function leadout_check_merged_contact()
{
    global $wpdb;
    global $wp_version;
    $stale_hash = $_POST['li_id'];
    $escaped_hash = '';
    if ($wp_version >= 4) {
        $escaped_hash = $wpdb->esc_like($stale_hash);
    } else {
        $escaped_hash = like_escape($stale_hash);
    }
    // Check if hashkey is in a merged contact
    $q = $wpdb->prepare("SELECT hashkey, merged_hashkeys FROM {$wpdb->li_leads} WHERE merged_hashkeys LIKE '%%%s%%'", $escaped_hash);
    $row = $wpdb->get_row($q);
    if (isset($row->hashkey) && $stale_hash) {
        // One final update to set all the previous pageviews to the new hashkey
        $q = $wpdb->prepare("UPDATE {$wpdb->li_pageviews} SET lead_hashkey = %s WHERE lead_hashkey = %s", $row->hashkey, $stale_hash);
        $wpdb->query($q);
        // One final update to set all the previous submissions to the new hashkey
        $q = $wpdb->prepare("UPDATE {$wpdb->li_submissions} SET lead_hashkey = %s WHERE lead_hashkey = %s", $row->hashkey, $stale_hash);
        $wpdb->query($q);
        // Remove the passed hash from the merged hashkeys for the row
        $merged_hashkeys = array_unique(array_filter(explode(',', $row->merged_hashkeys)));
        // Delete the stale hash from the merged hashkeys array
        $merged_hashkeys = leadout_array_delete($merged_hashkeys, "'" . $stale_hash . "'");
        $q = $wpdb->prepare("UPDATE {$wpdb->li_leads} SET merged_hashkeys = %s WHERE hashkey = %s", rtrim(implode(',', $merged_hashkeys), ','), $row->hashkey);
        $wpdb->query($q);
        echo json_encode($row->hashkey);
        die;
    } else {
        echo json_encode(FALSE);
        die;
    }
}
开发者ID:AndyGCook,项目名称:leadout,代码行数:39,代码来源:leadout-ajax-functions.php


示例6: wp_ajax_ajax_tag_search

function wp_ajax_ajax_tag_search()
{
    global $wpdb;
    if (isset($_GET['tax'])) {
        $taxonomy = sanitize_key($_GET['tax']);
        $tax = get_taxonomy($taxonomy);
        if (!$tax) {
            wp_die(0);
        }
        if (!current_user_can($tax->cap->assign_terms)) {
            wp_die(-1);
        }
    } else {
        wp_die(0);
    }
    $s = wp_unslash($_GET['q']);
    $comma = _x(',', 'tag delimiter');
    if (',' !== $comma) {
        $s = str_replace($comma, ',', $s);
    }
    if (false !== strpos($s, ',')) {
        $s = explode(',', $s);
        $s = $s[count($s) - 1];
    }
    $s = trim($s);
    if (strlen($s) < 2) {
        wp_die();
    }
    // require 2 chars for matching
    $results = $wpdb->get_col($wpdb->prepare("SELECT t.name FROM {$wpdb->term_taxonomy} AS tt INNER JOIN {$wpdb->terms} AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.name LIKE (%s)", $taxonomy, '%' . like_escape($s) . '%'));
    echo join($results, "\n");
    wp_die();
}
开发者ID:jcsilkey,项目名称:CodeReviewSecurityRepo,代码行数:33,代码来源:ajax-actions.php


示例7: search_terms

 function search_terms($search_terms, $taxon = 'tag', $limit = 10)
 {
     global $wpdb, $bp;
     $search_terms = like_escape($wpdb->escape($search_terms));
     $data = $wpdb->get_results($wpdb->prepare("\n         SELECT `id`, `name` FROM {$bp->gtm->table_terms}  WHERE `taxon` = %s AND `name` LIKE '%%{$search_terms}%%' LIMIT %d", $taxon, $limit));
     return $data;
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:7,代码来源:terms.php


示例8: tag_search

	function tag_search() {
		global $wpdb;
		$term = $_GET['term'];
		if ( false !== strpos( $term, ',' ) ) {
			$term = explode( ',', $term );
			$term = $term[count( $term ) - 1];
		}
		$term = trim( $term );
		if ( strlen( $term ) < 2 )
			die(); // require 2 chars for matching

		$tags = array();
		$results = $wpdb->get_results( "SELECT name, count FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = 'post_tag' AND t.name LIKE ( '%". like_escape( $wpdb->escape( $term ) ) . "%' ) ORDER BY count DESC" );

		foreach ( $results as $result ) {
			$rterm = '/' . preg_quote( $term, '/' ) . '/i';
			$label = preg_replace( $rterm, "<strong>$0</strong>", $result->name ) . " ($result->count)";

			$tags[] = array(
				'label' => $label,
				'value' => $result->name,
			);
		}

		echo json_encode( $tags );
	}
开发者ID:ramo01,项目名称:1kapp,代码行数:26,代码来源:ajax.php


示例9: shandora_posts_where

function shandora_posts_where($where, &$wp_query)
{
    global $wpdb;
    if ($post_title = $wp_query->get('post_title')) {
        $where .= ' AND ' . $wpdb->posts . '.post_title LIKE \'%' . esc_sql(like_escape($post_title)) . '%\'';
    }
    return $where;
}
开发者ID:VadimSid,项目名称:thinkgreek,代码行数:8,代码来源:theme-hooks.php


示例10: test_like_escape

 /**
  * @ticket 10041
  * @expectedDeprecated like_escape
  */
 function test_like_escape()
 {
     $inputs = array('howdy%', 'howdy_', 'howdy\\', 'howdy\\howdy%howdy_');
     $expected = array("howdy\\%", 'howdy\\_', 'howdy\\', 'howdy\\howdy\\%howdy\\_');
     foreach ($inputs as $key => $input) {
         $this->assertEquals($expected[$key], like_escape($input));
     }
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:12,代码来源:LikeEscape.php


示例11: posts_where

 function posts_where($where, &$wp_query)
 {
     global $wpdb;
     if ($title = $wp_query->get('like_title')) {
         $where .= " AND " . $wpdb->posts . ".post_title LIKE '%" . esc_sql(like_escape($title)) . "%'";
     }
     return $where;
 }
开发者ID:gjaya79,项目名称:urdailynews,代码行数:8,代码来源:relationship.php


示例12: ym_logs_search_users

function ym_logs_search_users()
{
    ym_ajax_superuser_check();
    $users = get_users('search=*' . like_escape(ym_get('q')) . '*');
    foreach ($users as $user) {
        echo $user->user_login . "\n";
    }
    die;
}
开发者ID:AdultStack,项目名称:ap-members,代码行数:9,代码来源:ym-admin_ajax_functions.include.php


示例13: get_ips

 public static function get_ips()
 {
     if (!defined('DOING_AJAX') || !current_user_can(MainWP_WP_Stream_Admin::SETTINGS_CAP)) {
         return;
     }
     check_ajax_referer('stream_get_ips', 'nonce');
     global $wpdb;
     $results = $wpdb->get_col($wpdb->prepare("\n\t\t\t\t\tSELECT distinct(`ip`)\n\t\t\t\t\tFROM `{$wpdb->mainwp_reports}`\n\t\t\t\t\tWHERE `ip` LIKE %s\n\t\t\t\t\tORDER BY inet_aton(`ip`) ASC\n\t\t\t\t\tLIMIT %d;\n\t\t\t\t", like_escape($_POST['find']) . '%', $_POST['limit']));
     wp_send_json_success($results);
 }
开发者ID:HasClass0,项目名称:mainwp-child-reports,代码行数:10,代码来源:settings.php


示例14: wpmoly_esc_like

/**
 * Escape a string to use in SQL LIKE.
 * like_escape() is deprecated since WordPress 4.0 which introduces a $wpdb
 * method. This is for compatibility easiness with WP<4.x
 * 
 * @since    2.1
 * 
 * @param    string    $string Data to escape
 * 
 * @return   string    Escape string
 */
function wpmoly_esc_like($string)
{
    global $wpdb;
    if (method_exists('wpdb', 'esc_like')) {
        $string = $wpdb->esc_like($string);
    } else {
        $string = like_escape($letter);
    }
    return $string;
}
开发者ID:masterdoed,项目名称:wpmovielibrary,代码行数:21,代码来源:wpmoly-core-functions.php


示例15: post_lookup

function post_lookup()
{
    global $wpdb;
    $search = like_escape($_REQUEST['q']);
    $query = 'SELECT ID,post_title FROM ' . $wpdb->posts . '
      WHERE post_title LIKE \'' . $search . '%\'
      AND post_status = \'publish\'
      ORDER BY post_title ASC';
    die;
}
开发者ID:globalfoodbook,项目名称:promote-posts,代码行数:10,代码来源:promote-posts.php


示例16: prepare_items

 function prepare_items()
 {
     global $frmdb, $wpdb, $per_page, $frm_settings;
     $paged = $this->get_pagenum();
     $default_orderby = 'name';
     $default_order = 'ASC';
     if ($this->plural == 'entries') {
         $default_orderby = 'id';
         $default_order = 'DESC';
     }
     $orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : $default_orderby;
     $order = isset($_REQUEST['order']) ? $_REQUEST['order'] : $default_order;
     $page = $this->get_pagenum();
     $per_page = $this->get_items_per_page('formidable_page_formidable_' . str_replace('-', '_', $this->page_name) . '_per_page');
     $start = isset($_REQUEST['start']) ? $_REQUEST['start'] : ($page - 1) * $per_page;
     $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
     $fid = isset($_REQUEST['fid']) ? $_REQUEST['fid'] : '';
     if ($s != '') {
         $s = stripslashes($s);
         preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
         $search_terms = array_map('_search_terms_tidy', $matches[0]);
     }
     $s_query = '';
     if ($this->plural == 'entries') {
         global $frm_entry, $frmpro_entries_controller;
         $form_id = $this->params['form'];
         $s_query = 'it.form_id=' . (int) $form_id;
         if ($s != '') {
             $s_query = $frmpro_entries_controller->get_search_str($s_query, $s, $form_id, $fid);
         }
         $this->items = $frm_entry->getAll($s_query, " ORDER BY {$orderby} {$order}", " LIMIT {$start}, {$per_page}", true, false);
         $total_items = $frm_entry->getRecordCount($s_query);
     } else {
         if ($this->plural == 'displays') {
             global $frmpro_display, $frm_app_helper;
             if (isset($_REQUEST['form']) and is_numeric($_REQUEST['form'])) {
                 $s_query .= "form_id=" . (int) $_REQUEST['form'];
             }
             if ($s != '') {
                 foreach ((array) $search_terms as $term) {
                     $term = esc_sql(like_escape($term));
                     if (!empty($s_query)) {
                         $s_query .= " AND";
                     }
                     $s_query .= " (name like '%{$term}%' OR description like '%{$term}%' OR created_at like '%{$term}%' OR content like '%{$term}%' OR dyncontent like '%{$term}%')";
                     unset($term);
                 }
             }
             $this->items = $frmpro_display->getAll($s_query, " ORDER BY {$orderby} {$order}", " LIMIT {$start}, {$per_page}", true, false);
             $total_items = $frm_app_helper->getRecordCount($s_query, $this->table_name);
         }
     }
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page));
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:54,代码来源:FrmProListHelper.php


示例17: get_like

 /**
  * Returns the SQL escaped like value for auto suggest queries.
  *
  * @since 1.2.3
  * @return string
  */
 public static function get_like()
 {
     global $wpdb;
     $like = stripslashes(urldecode($_REQUEST['fl_as_query']));
     if (method_exists($wpdb, 'esc_like')) {
         $like = esc_sql($wpdb->esc_like($like));
     } else {
         $like = like_escape(esc_sql($like));
     }
     return $like;
 }
开发者ID:nullality,项目名称:FEWD-SEA-7,代码行数:17,代码来源:class-fl-builder-auto-suggest.php


示例18: json_search_customer_name

 public static function json_search_customer_name($query)
 {
     global $wpdb;
     $term = wc_clean(stripslashes($_GET['term']));
     if (method_exists($wpdb, 'esc_like')) {
         $term = $wpdb->esc_like($term);
     } else {
         $term = like_escape($term);
     }
     $query->query_from .= " INNER JOIN {$wpdb->usermeta} AS user_name ON {$wpdb->users}.ID = user_name.user_id AND ( user_name.meta_key = 'first_name' OR user_name.meta_key = 'last_name' ) ";
     $query->query_where .= $wpdb->prepare(" OR user_name.meta_value LIKE %s ", '%' . $term . '%');
 }
开发者ID:hernanimattos,项目名称:LearnPress,代码行数:12,代码来源:class-lp-admin-ajax.php


示例19: advanced_search_query

 function advanced_search_query($where)
 {
     if (is_search() && '1' === wpsf_get_setting(wpsf_get_option_group('../settings/settings-general.php'), 'search', 'enabled')) {
         global $wpdb;
         $query = get_search_query();
         $query = like_escape($query);
         // include postmeta in search
         $where .= " OR {$wpdb->posts}.ID IN (SELECT {$wpdb->postmeta}.post_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->postmeta}.meta_key = 'pl-settings' AND {$wpdb->postmeta}.meta_value LIKE '%{$query}%' AND {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id)";
         // include taxonomy in search
         $where .= " OR {$wpdb->posts}.ID IN (SELECT {$wpdb->posts}.ID FROM {$wpdb->posts},{$wpdb->term_relationships},{$wpdb->terms} WHERE {$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id AND {$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->terms}.term_id AND {$wpdb->terms}.name LIKE '%{$query}%')";
     }
     return $where;
 }
开发者ID:benpeck,项目名称:experticity-fools,代码行数:13,代码来源:class.hacks.php


示例20: filter_posts

 /**
  * Filter the query based on selected values
  */
 function filter_posts($params)
 {
     global $wpdb;
     $facet = $params['facet'];
     $selected_values = $params['selected_values'];
     $selected_values = is_array($selected_values) ? $selected_values[0] : $selected_values;
     // like_escape was deprecated in 4.0
     $selected_values = method_exists($wpdb, 'esc_like') ? $wpdb->esc_like($selected_values) : like_escape($selected_values);
     if (empty($selected_values)) {
         return 'continue';
     }
     $sql = "\n        SELECT DISTINCT post_id FROM {$wpdb->prefix}facetwp_index\n        WHERE facet_name = '{$facet['name']}' AND facet_display_value LIKE '%{$selected_values}%'";
     return $wpdb->get_col($sql);
 }
开发者ID:durichitayat,项目名称:befolio-wp,代码行数:17,代码来源:autocomplete.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP like_function函数代码示例发布时间:2022-05-15
下一篇:
PHP like函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap