[support] db_select()->condition()
Metzler, David
metzlerd at evergreen.edu
Wed Jul 11 16:05:11 UTC 2012
I seem to be missing some of the messages on this thread, so I apologize
if this question has already been answered more thoroughly.
You appear to be confusing db_query syntax with db_select. The query
builder does not take tokens. This might help grok db_select.
db_select('mytable', 'mt')
->fields('mt', array('mycolumn'))
->condition('mycolumn', '%' . $mystring . '%', 'LIKE')
->execute();
Like is particularly confusing because it basically takes a regular
expression inside the quotes.
Hope this helps... Dave
On 7/11/2012 6:30 AM, John Summerfield wrote:
> Earnie Boyd wrote:
> > I have an existing module I'm trying to convert to DBTNG and have a
> > condition I need a suggestion on.
> >
> > Original statement is something like
> > SELECT mt.myvar FROM {mytable} mt WHERE mystring LIKE '%%%s%%';
> >
> > I want to change it to
> > db_select('mytable', 'mt')
> > ->fields('mt', array('myvar'))
> > ->condtion('mystring', '%:mystring%', LIKE)
> > ->execute();
> >
> > The problem is condition() only takes three parameters, what would
you
> > suggest to use to replace :mystring? I'm using t() but that seems
> > like a misuse of it.
> >
--
[ Drupal support list | http://lists.drupal.org/ ]
More information about the support
mailing list