Within a MySQL query, is it possible to put a PHP function around a field name in order to change/replace its value?
SELECT * FROM my_table WHERE url_title(field_name) = '$variable'
The reason for asking is that the '$variable' in my URL which the query will use is an edited version (using Codeigniter's url_title
function) of its true value eg. $variable = 'dangelo'
whereas its true value in field name is "D'Angelo".
url_title()
is making a URL slug - once it is changed to "dangelo" it cannot be reversed to "D'Angelo" - it is normal to store these values separately. One for the URL and the other for the page title.WHERE some_complicated_function(column) = 'some value'
in your query will hurt performance, especially when you have thousands of articles. You should consider halfer's suggestion.$var = url_title(field_name)
and the query would beSELECT * FROM my_table WHERE $var = '$variable'