php - How to create a dynamic query?
Get the solution ↓↓↓I have a string like this:
$str = "It is a test. 10".
Also I have two query:
One: The above string is not containing any "number": (Imagine this:$str = It is a test.
)
So, here is the query:
select * from table where match(col1,col2,co3) against('$str')
Two: The above string is containing some "number":
First of all I separate that number from string like this:
preg_match_all('!\d+!', $str, $matches);
an then here is the query:
select * from table where match(col1) against('$str') and col4 IN (" .implode(',', $matches[0]) . ")";
union all
select * from table where match(col1,col2,co3) against('$str')
Always one of those queries will be run (according to the condition). Now, I want to know, How can implement a dynamic query?
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: string literal contains an unescaped line break
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.