PDA

View Full Version : Run PHP from database


ajhalls
03-17-2014, 09:51 PM
Good afternoon,
What do I need to do to get some php code that is stored in the database to not just display as text, but to execute? I have a field (samplecode) in one of my tables that needs to run similar to the plugin code but it is stored in a different table.

In the php in the file, I have a database query which is pulling all the relevant data
$toolkit = $db->query_first(xxx);

Should there be in the plugin system something where I do something like:

ob_start();
$toolkit.samplecode;
$html .= ob_get_contents();
ob_clean();

and then call the plugin from within the template with {vb:raw samplecode}

--------------- Added 1395152452 at 1395152452 ---------------

Found it. I was close, no need to mess with the plugin system at all, I was just missing a little bit :)

ob_start();
eval ($toolkit['samplecode']);
$samplecode = ob_get_contents();
ob_clean();

$templater->register('samplecode', $samplecode);