hey guys I have an SQL in PHP with PDO method and I want use my function inside this SQL.
My function:
function columns(){
return "id,name";
}
My SQL code:
try{
$connection->beginTransaction();
$connection->exec("INSERT INTO table (".columns().") VALUES (1,'John')");
$connection->commit();
}catch(...){
...
}
But its not working what can i do help me please.
The SQL is becoming like this :
INSERT INTO table() VALUES (1,'John')
The problem is the columns() function is not returning on the SQL but if we print the columns() function its will print. (tested with print_r(columns());)