CodeIgniter Forums
database item containing CI code - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: database item containing CI code (/showthread.php?tid=32218)



database item containing CI code - El Forum - 07-16-2010

[eluser]Ajaxian64[/eluser]
Hello
I have an table in a database in which I have a column: 'article'
In this article I store pure Html code and also CI code.
For instance I store text with anchor, images .. and so I use CI helper code (html, url...)

In my controller I get the contain of the article from DB, and send it to the view.
In the view, I do
Code:
<?php echo $article->row()->contain; ?>

But when I display the contain of this article, html si correct but the CI code is not interpreted.

Is there a mean to store in database CI code which can be interpreted when displayed in a view ?


database item containing CI code - El Forum - 07-16-2010

[eluser]danmontgomery[/eluser]
What's the benefit of storing PHP? This only makes your life more difficult... Why not store everything as HTML, already interpreted?


database item containing CI code - El Forum - 07-16-2010

[eluser]Ajaxian64[/eluser]
I loose CI facilities
I must write entire path for accessing images, anchor ...


database item containing CI code - El Forum - 07-16-2010

[eluser]WanWizard[/eluser]
Use a template engine, so you can store the template including template variables, but do the parsing at runtime.

Storing code in the database is not a good idea. You could use eval() to deal with the code, but it is generally frowned upon (it might be a huge security risk).


database item containing CI code - El Forum - 07-16-2010

[eluser]Ajaxian64[/eluser]
thanks