[support] Place holders in SQL query
Greg Knaddison
greg at growingventuresolutions.com
Mon Apr 11 01:33:03 UTC 2011
On Sun, Apr 10, 2011 at 6:55 PM, Austin Einter <austin.einter at gmail.com> wrote:
>
> 2.
> I am facing a below typical problem, can somebody tell me what should I do?
>
> Below query works fine.
> SELECT skillid FROM {resubmt_skills} WHERE resubmt_skills.skillname IN
> ('PHP', 'HTML', 'SQL')
>
> But in above query search string 'PHP', 'HTML', 'SQL' is hard coded.
> I want to make the query generic.
>
> Lets say in custom search form, user entered search string PHP, Telecom,
> HTML,, so how can I write a generic query.
>
There's a handy function you need called db_placeholders -
http://api.drupal.org/api/drupal/includes--database.inc/function/db_placeholders/6
There are some examples on that page, but if you want more help be
sure to provide more of your example code.
Cheers,
Greg
--
Greg Knaddison | 720-310-5623 | http://growingventuresolutions.com
http://masteringdrupal.com - Videos and Tutorials
More information about the support
mailing list