Database calls from single page
Permalink
I added a new schema to my MySQL server for some stuff that I'm bolting on to a C5 installation.
I gave the C5 user access to the new schema. What's the best way to do a prepared insert to one of those new tables? Can I use the existing connection or should I create a new one? Can I use Loader::db() with my new schema?
Thanks!
I gave the C5 user access to the new schema. What's the best way to do a prepared insert to one of those new tables? Can I use the existing connection or should I create a new one? Can I use Loader::db() with my new schema?
Thanks!
I'm familiar with the MVC pattern (in concept), but I have no idea how to actually implement that in PHP/C5. My PHP skills are decent, but they are very non-OO.
Thanks for the link, though. I'll check it out.
Thanks for the link, though. I'll check it out.
well, there aren't that many MVC functions in Concrete5. You can derive your model classes from adodb record, but most models simply inherit "object" and nothing else..
The controllers do have a couple of methods like set('myVar', 'myValue) but it's mostly php stuff and not a lot c5 specific stuff to learn.
The controllers do have a couple of methods like set('myVar', 'myValue) but it's mostly php stuff and not a lot c5 specific stuff to learn.
How would we get database credentials from c5 if this is in a package being sold in the marketplace?
I'm not entirely sure what you are asking. Add-ons in the Marketplace will probably be using C5's existing database connection. Otherwise, the database credentials are stored in C5's config file, so an add-on could pull the creds from there. Did I even get close to what you are asking?
I think someonese tried to use Loader::db to access a different database but it didn't work. Not sure if it has changed but you might have to create a second adodb connection..
http://phplens.com/lens/adodb/docs-adodb.htm...
By the way, I don't recommend to add database calls in your single page, you should use controllers, models and single_pages whenever possible. Makes it easier to read the code for another developer..