|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
MDB2 and like queries
I am not sure if this topic has been discussed before but I tried google and I have tried searching this forum but couldn’t find the solution.
Ok I am new to MDB2 but not to PHP. Anyways, I am stuck with how to incorporate “like” queries within prepared statements. Is there a way to do it or we can’t do them right now? If yes, then some example would be helpful. Right now I am just running the query using $con->query($qry), but I am hoping that there is some way I can use the prepared query. Thanks in advance |
|
#2
|
|||
|
|||
|
Which problem(s) do you see with LIKE in prepared statements? It should work exactly the same as usual comparisons do.
|
|
#3
|
|||
|
|||
|
Quote:
it was some unknown error, I will paste query tomorrow its not with me right now. but my qry was like "select col1,col2 from table where col2 like '%:data%'" where :data was a placeholder. thanks |
|
#4
|
|||
|
|||
|
and I used a data array to fill this :data placeholder.
|
|
#5
|
|||
|
|||
|
Quote:
That can't work. If the replaced part would be quoted (<= very likely for strings, of course), you would get something like select [...] where col2 like '%"example"%' Therefore, MDB2 is smart enough to reject things like this. Using "select col1,col2 from table where col2 like :data" should work if you put the percentage signs yourself around the variable. |
|
#6
|
|||
|
|||
|
yea thanks it worked
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PEAR Packages > MDB2 and like queries |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|