I am using Laravel 5. I need to save some sql statements in a field of a table of the database (these statements are used to get some results). I want to get these statements in my controller and execute them using Laravel, but the statements are only strings, Let's suppose the following
$statement = Table::where('ID', 1);
$statement = $statement->STATEMENT;
In $statement I have a string like this
$statement = 'SELECT SUM(VAL) FROM TABLE';
What I need to know is how to execute in the database the statement saved in my string var $statement
I finally want to have something like
$result = 10 (the result of executing 'SELECT SUM(VAL) FROM TABLE', which was in $statement)
Thanks!
statementbut dont how execute it?