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 );