Gaboog
Forum Replies Created
-
Forum: Hacks
In reply to: Query posts by title – Custom query neededDear markparolisi,
How do you mean LIKE queries are expensive? Too many bandwidth or overload the server? I don’t really prefer caching in general.
Thank you in advance.
Best Regards,
GabooForum: Hacks
In reply to: Query posts by title – Custom query neededDear Michael,
Thank you for your answer. By the time I made it work.
My query looks like as follows:
$keyword = sanitize_text_field( $_REQUEST['keyword'] ); $keyword = "%{$keyword}%"; $post_ids_post = $wpdb->get_results( $wpdb->prepare( " SELECT ID,post_content,post_title,post_parent,guid,post_type FROM {$wpdb->posts} WHERE (post_title LIKE '%s' OR post_content LIKE '%s') AND post_type='attachment' AND (post_parent=2068 OR post_parent=2070 ) ", $keyword,$keyword ) );
Thank you for your contribution.
Best Regards,
GabooForum: Hacks
In reply to: Query posts by title – Custom query neededDear Michael,
Thank you for your reply.
I thought
%s
is for escaping.Well, get back to the first query.
So how would that be possible to run this query correctly in wordpress conditions to get result which not NULL? (Native php-mysql statements doesn’t work.) I tried `$a = $wpdb->get_results($q,Array_A);
var_dump($events);`, but it gave NULL.I ran the query you wrote first and worked fine in phpmyadmin.
Thank you in advance.
Best Regards,
GabooForum: Hacks
In reply to: Query posts by title – Custom query neededDear Michael,
Thank you for your reply.
And how would that be possible to run this query correctly in wordpress conditions? (Native php-mysql statements doesn’t work.)
Do you think do code below could be adjusted to do this? If yes how?
Thank you in advance.
Best Regards,
Gaboo[Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]