What I want to do is while executing MySQL query, passing column data into a PHP function and comparing the result with WHERE clause…
Something like that, I have the slug() function which I wrote in PHP and my query will be something like;
SELECT * FROM articles WHERE slug(author) = "james-taylor";
So the query will select “author” column and pass it to slug() function and compare returning data with “james-taylor”.
Anybody have any ideas? Thanks in advance 🙂
There’s not a way to use a PHP function directly in mysql.
You would need to use mysql string functions to duplicate your slug function in mysql. (http://dev.mysql.com/doc/refman/5.0/en/string-functions.html)
Another option would be to have a field named “slug” and to use the php function to generate slugs for all of your records in the table. Then you can say “select * from articles where slug = ‘james-taylor’;