I have a field database record row that reads like this:
| id | command |
------------------
| 1 | getName() |
I also have a PHP entity that is User, and has the getName()
function.
Assuming the database record is read and parsed into $record and I have $user, how do I concatenate $record with the $user command?
I tried $user-> . $record['command']
but obviously does not work. I want to avoid hardcoding as I need it to be dynamic if possible.
Example of code:
$record = DB::queryFirstRow("SELECT * from command_records WHERE id='1'");
$user = new User("Kenny");
// Here is where I'm trying to perform the $user->getName()
// by reading $record['command']. $record['command'] is getName()
$user-> . $record['command'];
It of course fails. I'm thinking of eval from googling earlier but can't get it to work out too.