PHP convert plain text to MS SQL where condition

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
recuerdeme
Forum Newbie
Posts: 2
Joined: Thu Nov 11, 2010 9:24 am

PHP convert plain text to MS SQL where condition

Post by recuerdeme »

Background:
We have an application running in MS Access that allows users to search all text fields dropdowns etc using Access's built in functionality.

I'm tasked with moving this to the web.
So I want to allow the users to type plainly there condition in the field and convert to sql statements
array of things to look for is ('NOT LIKE', 'LIKE', 'IS NULL', 'IS NOT NULL', '>', '<', 'BETWEEN') and ('AND', 'OR')

I'm currently lost in the loops to parse out the information
For instance
Say a user searched name field
User types: like Barb and Joe and not like Barbara and is not null
I want to convert this into sql and place in the where clause of my query
ie where (name like 'barb' or name like 'joe') and (name not like 'Barbara') and name is not null

Any help? Or point me to where it has already been done.

Thanks
Post Reply