By SmokOO on
Hi!
I've got a strange problem... for the same query phpMyAdmin returns 4 results and db_query() returns none. Here is the query:
select * from log where log_data <= '2010-12-04' and log_data >= '2010-04-04' and typ LIKE '%dodanieSprzetu%'
the funny thing is that for similar query both phpMyAdmin and db_query() return correct number of result:
select * from log where log_data <= '2010-12-04' and log_data >= '2010-03-04' and typ LIKE '%edycjaSprzetu%'
and now I have no clue what is wrong. Thx for any help or advice!
[Edit:] changed title from 'query problem' pbarnett
Comments
db_query takes placeholders,
db_query takes placeholders, which include %d. If you want to use the percent sign in your query, you need to escape it with another percent sign:
'%%dodanieSprzetu%%'But really, you should be doing this:
Contact me to contract me for D7 -> D10/11 migrations.
big THX!
big THX!
Please change title and follow forum guidelines
Hi,
Please follow the forum guidelines here http://drupal.org/forum-posting
Please help other folks find an answer to your issue. How about renaming you subject to something like "Using "%" and "like" with db_query()" or "Using a percent sign with db_query". A subject line that will allow other folks to find the issue and answer, :) :) Thank you ahead of time :)
Thanks a lot! You have saved
Thanks a lot! You have saved me many hours.
I was a little confused by this occasion.