开发者

Drupal db_query error need help

开发者 https://www.devze.com 2022-12-26 21:22 出处:网络
im using drupal 6.15 and doing my first project in drupal . i got an issue while running the below query with db_query

im using drupal 6.15 and doing my first project in drupal . i got an issue while running the below query with db_query

i have drupal,delhi keywords in column 'tag' with table name tagging.

db_query(SELECT * FROM {tagging} WHERE tag LIKE '%drup%') wont retrieve the correct output.

it show null but the query modified like this,

db_query(S开发者_如何学编程ELECT * FROM {tagging} WHERE tag LIKE 'drup%') retrieve "drupal" as output

finally i used the php core mysql_query

mysql_query(SELECT * FROM tagging WHERE tag LIKE '%drup%') it retrieve the exact n correct output "drupal" .

is any one have solution ,

Thanxs, Gobi


It is best for security reasons to use modifiers in db_query.

The following modifiers are available: (see http://api.drupal.org/api/function/db_query)

%s for strings
%d for integer
%f for floating point
%b for binary type
%% for %

Write your query as follows:

$sql = "SELECT * FROM {tagging} WHERE tag LIKE '%%%s%%'";  
db_query($sql, "drup"); 
0

精彩评论

暂无评论...
验证码 换一张
取 消