3

How can i use LIKE operator in this sql statement using medoo framework?

Original SQL statement:

SELECT id,name FROM table WHERE name LIKE %'foo'%

medoo statement:

$data=$db->select('table',
    ['id','name'],
    ['AND' => ['name' => 'foo']
    ]
);

thanks for your help!

Hechi
  • 281
  • 4
  • 14
  • 1
    `LIKE condition can be use it like basic condition or relativity condition with just adding [~] syntax now.`. http://medoo.in/api/where (not the best grammar on the statement by them) Also for future reference Googling `medoo like operator` brought that link as the first result. – chris85 Jul 19 '16 at 14:45

2 Answers2

5

Use like condition like this [~] Refer the link

$data=$db->select('table',
    ['id','name'],
    ['AND' => ['name[~]' => 'foo']

]);
I'm Geeker
  • 4,601
  • 5
  • 22
  • 41
2
$data = $db->select('table',['id','name'],['name[~]' => 'foo']);
Maulik Patel
  • 650
  • 5
  • 22
  • While this code snippet may solve the question, [including an explanation](//meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please also try not to crowd your code with explanatory comments, as this reduces the readability of both the code and the explanations! – Blue Jul 21 '16 at 08:24