Welcome Guest, Not a member yet? Register   Sign In
database item containing CI code
#1

[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 ?
#2

[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?
#3

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

[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).
#5

[eluser]Ajaxian64[/eluser]
thanks




Theme © iAndrew 2016 - Forum software by © MyBB