Is there any way to use a function in sql like this:
$title = clean_title($title);
"SELECT * FROM article WHERE title = $title"
to
$title = clean_title($title);
"SELECT * FROM article WHERE clean_title(title) = $title"
is ther any way?
Is there any way to use a function in sql like this:
$title = clean_title($title);
"SELECT * FROM article WHERE title = $title"
to
$title = clean_title($title);
"SELECT * FROM article WHERE clean_title(title) = $title"
is ther any way?
No.
Much in the same way that server-side code and client-side code are evaluated by entirely different platforms at entirely different times, the same is true with database code.
In this case, think of the database as the server and the PHP engine as the client.
Your PHP code is building SQL code which will later be evaluated by the database. In your PHP code you can invoke PHP functions to drive the creation of that SQL code. But once that SQL code gets to the database, PHP is no longer involved. The database engine can only evaluate SQL code, not PHP code.
There is a significant amount of logic that can be expressed in SQL code, including built-in functions or custom functions/procedures you can define (depending very much on the SQL engine being used). But that logic needs to be defined in SQL, not in PHP.
Because you add the PHP tag, i assume it's an option to use PHP as well. In PHP you can use something like this:
$SQL = "SELECT * FROM article WHERE ".clean_title($title)." = $title"