PEAR Packages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPEAR Packages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old September 30th, 2007, 05:29 AM
msaad msaad is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 6 msaad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 11 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old September 30th, 2007, 07:35 AM
wiesemann wiesemann is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 153 wiesemann User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 29 m 35 sec
Reputation Power: 2
Which problem(s) do you see with LIKE in prepared statements? It should work exactly the same as usual comparisons do.

Reply With Quote
  #3  
Old September 30th, 2007, 02:30 PM
msaad msaad is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 6 msaad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 11 sec
Reputation Power: 0
Quote:
Originally Posted by wiesemann
Which problem(s) do you see with LIKE in prepared statements? It should work exactly the same as usual comparisons do.



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

Reply With Quote
  #4  
Old September 30th, 2007, 02:31 PM
msaad msaad is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 6 msaad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 11 sec
Reputation Power: 0
and I used a data array to fill this :data placeholder.

Reply With Quote
  #5  
Old September 30th, 2007, 03:43 PM
wiesemann wiesemann is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 153 wiesemann User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 29 m 35 sec
Reputation Power: 2
Quote:
Originally Posted by msaad
but my qry was like

"select col1,col2 from table where col2 like '%:data%'"

where :data was a placeholder.


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.

Reply With Quote
  #6  
Old October 1st, 2007, 03:13 AM
msaad msaad is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 6 msaad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 11 sec
Reputation Power: 0
yea thanks it worked .

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPEAR Packages > MDB2 and like queries


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT