Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Including PHP stored in MySQL DB

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
ATKOgirl
Smarty n00b


Joined: 18 Nov 2003
Posts: 2

PostPosted: Tue Nov 18, 2003 6:40 pm    Post subject: Including PHP stored in MySQL DB Reply with quote

Hi Everyone,

We have a database of over 37,000 products. For each of those products, we have a php script stored in the database to "fetch" the product description from a supplier's web site.

Is their any way we can use include_php to access the script from the database for each product? I know {include_php file=x.php} can be used to access a php file, but we need to access from the database.

For instance, something like:

{include_php=products.fieldname}

Any assistance or advice anyone can offer is greatly appreciated.

Thanks in advance!
ATKOgirl
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Nov 18, 2003 7:27 pm    Post subject: Reply with quote

hmmm and double hmmm. This really isn't a job for smarty, imho.

Anyways, here's an idea though I suppose you don't want a runtime solution--still, you might be able to abuse the resource api to do something along these lines. ...and I do mean abuse!

{include file="phpdb:blah"}

Your phpdb resource would have to implement its source function so that instead of simply returning whatever blah points to in your database, it instead executes it. You now have the problem that if you return the results of that processing to Smarty, it will try to compile those results as if it was smarty code. You can either echo the results and return nothing or perhaps choose some funky delimiters.

You probably want to get this at compile time in which case I'd sugest investigating writing your own custom include plugin. Again, try to first find a way of doing this outside of Smarty if at all possible.
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Nov 18, 2003 9:05 pm    Post subject: Reply with quote

you can use resources with include_php. read: http://smarty.php.net/manual/en/templates.from.elsewhere.php

most of the things that are said about smarty-sources there apply also for php-sources when used with include_php (is_secure is for ".tpl", is_trusted is for ".php")

so you can read php-sources like template-sources from an abstract resource like your database.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Nov 18, 2003 9:39 pm    Post subject: Reply with quote

grrr. my bad. serves me right for never using include_php. Thanks for clearing that up, messju!! Smile
Back to top
View user's profile Send private message
ATKOgirl
Smarty n00b


Joined: 18 Nov 2003
Posts: 2

PostPosted: Wed Nov 19, 2003 2:18 am    Post subject: Reply with quote

Hi messju and boots,

Thank you both for your replies. I'll have a read and give it a try. I'm sure I'll be back for help...

Thanks again, I really appreciate your assistance!

ATKOgirl
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP