Page 1 of 1

Including sql requests as part of a page on cmcms?

Posted: Thu Jan 18, 2007 4:10 pm
by AndyHolyer
We are trying to replace a set of ASP scripts with a more principled solution, and cmsms is a strong candidate.

The scripts fetch data from an SQL database hosted on another server on our site, which I want to place into a template.

Since cmsms works with mysql to store its content, I'm guessing it should be pretty easy to link SQL connections into content, but I can't find any mentions from searching the site.

Am I totally insane to think of doing this? Or is is dead easy?

Thanks in advance for any advice

Andy Holyer
Sussex Downs College, Lewes, UK

Re: Including sql requests as part of a page on cmcms?

Posted: Thu Jan 18, 2007 4:31 pm
by calguy1000
You're not totally insane, but it's not dead easy either.

You'll have to know some php, and then create a user defined tag, a plugin, or a module (depending upon the complexity of what you need), that creates a mysql connection, queries the data, and then outputs it.

There are a few examples in the forge of plugins, etc, that access a different database, and plug that data into cms made simple.  I'd look for the 'quote of the day' plugin if it's still available in the forge as a good, though simplistic example.

Re: Including sql requests as part of a page on cmcms?

Posted: Thu Jan 18, 2007 8:35 pm
by AndyHolyer
I'll probably be tarred and feathered for this, but I'm an old Perl Fart; however when the choice is PHP or ASP, what do you think I would choose?

I'm minded to write a module to include arbitrary database connections, since (being in Further Education) there's a range of data sources owned by other departments who will not confirm  out of principle, so I will have to access whatever database they choose to use.

If I can get that in place, then it should all be easy :-/ Am I totally wrong in thinking that as a prerequisite I get PEAR so that I get the DB interfaces?

Re: Including sql requests as part of a page on cmcms?

Posted: Thu Jan 18, 2007 9:42 pm
by calguy1000
I don't know about PEAR, but it is also possible to use multiple adodb connections within a CMS module.  You just have to create new adodb objects for each of them.  Not such a big deal.

If you're connecing to multiple different types of databases, you may need to require PEAR (/me adds that to his reading list).  but ADODB_lite, or adodb should be able to handle most of em.

CMS Made Simple 1.0.2 (and as of today 1.0.3) ships with adodb-lite.  And adodb should work just fine.