[support] db_select()->condition()

John Summerfield summer at js.id.au
Wed Jul 11 10:30:20 UTC 2012


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.
> 


I have just read an email to the developer list where you, I felt, were 
quite rude towards someone who, in your estimation, asked a question on 
the wrong list.

Now I see a question of yours on what I suspect is the wrong list.

According to the mailman page for the support list, "If you need help 
with getting Drupal up and running this is the list for you."

It seems to me you are hacking on code, not trying to get Drupal up and 
running.


It happens I agree with you on the distinction between the two lists, I 
asked a little while ago and this seemed to be the majority view.

However, I would not reply to someone's question (or others' answers) 
just to castigate them for their stupidity.

Now to your question:
1. The code you posted contains at least one typo. It has no prospect of 
working as you showed it.
2. Did you read this?
http://api.drupal.org/api/drupal/includes!database!database.inc/function/db_select/7





-- 


Cheers
John Summerfield.




More information about the support mailing list