[support] Drupal 5 db_query
Fred Jones
fredthejonester at gmail.com
Mon Sep 22 11:06:14 UTC 2008
Here is some trivial code:
$n= db_query($countsql) ;
echo "<!-- ";print_r(db_fetch_array($n)); echo " -->";
$countsql = str_replace('{','',$countsql);
$countsql = str_replace('}','',$countsql);
$resultXXX = mysql_query($countsql);
echo "<!-- ";print_r(mysql_fetch_array($resultXXX)); echo " -->";
which runs my $countsql through db_query, shows the result and then
through mysql_query and shows the results. The two other lines just
remove the { and } characters. I would have expected to see the same
results both times, but what I see is:
<!-- Array
(
[COUNT(*)] => 0
)
--><!-- Array
(
[0] => 4
[COUNT(*)] => 4
)
-->
The mysql_query version returns the correct result--that is what I see
if I run the query via phpMyAdmin as well. Seems that Drupal's
db_query is doing something to it. The operative issue is the use of
UCASE I am quite certain. I wanted to make my LIKE phrase case
insensitive, so I added UCASE to both sides of it, but now db_query
fails.
Anyone have any feedback on this? I would not be opposed to just using
mysql_query but the query in question I actually want to pass to
pager_query, which in turn of course passes it to db_query.
Thanks.
More information about the support
mailing list