admin管理员组文章数量:1336394
I use this code:
$search = $this->wpdb->prepare("WHERE (name LIKE %s OR tag LIKE %s)", '%'. $this->wpdb->esc_like($word) .'%', '%'. $this->wpdb->esc_like($word) .'%');
and in console i get:
name LIKE '{4b9ad9b602bd32ff99324feebaa1883bb3a3e818f587b35198d4e48093375c78}night{4b9ad9b602bd32ff99324feebaa1883bb3a3e818f587b35198d4e48093375c78}' OR tag LIKE '{4b9ad9b602bd32ff99324feebaa1883bb3a3e818f587b35198d4e48093375c78}night{4b9ad9b602bd32ff99324feebaa1883bb3a3e818f587b35198d4e48093375c78}'
how i can remove this strange string?
I use this code:
$search = $this->wpdb->prepare("WHERE (name LIKE %s OR tag LIKE %s)", '%'. $this->wpdb->esc_like($word) .'%', '%'. $this->wpdb->esc_like($word) .'%');
and in console i get:
name LIKE '{4b9ad9b602bd32ff99324feebaa1883bb3a3e818f587b35198d4e48093375c78}night{4b9ad9b602bd32ff99324feebaa1883bb3a3e818f587b35198d4e48093375c78}' OR tag LIKE '{4b9ad9b602bd32ff99324feebaa1883bb3a3e818f587b35198d4e48093375c78}night{4b9ad9b602bd32ff99324feebaa1883bb3a3e818f587b35198d4e48093375c78}'
how i can remove this strange string?
Share Improve this question asked May 28, 2020 at 22:09 manandmanmanandman 352 bronze badges1 Answer
Reset to default 2That is a placeholder escape string generated by wpdb::placeholder_escape()
which is used by wpdb::add_placeholder_escape()
and which is called by wpdb::prepare()
.
So it is safe to keep those escape strings, but there is a wpdb
method for removing them: wpdb::remove_placeholder_escape()
:
// In your case, you'd use $this->wpdb in place of $wpdb.
$query = $wpdb->add_placeholder_escape( 'LIKE %night%' );
$query2 = $wpdb->remove_placeholder_escape( $query );
var_dump( $query, $query2 );
本文标签: Strange string in console from wpdb query
版权声明:本文标题:Strange string in console from wpdb query 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742392041a2466182.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论