I have a pretty straight forward application need. A. Two separate input forms ==> insert to two separate MySQL tables B. Joined query on these two tables ==> retrieved recs ==> table ==> display
I am currently on EE 2.2.2.
What might be my quickest and easiest approach?
Any and all suggestions are very much appreciated. Code examples I could follow and clone would be absolutely super.
Thanks!! Larry A.
Hi Larry,
If you’re comfortable with writing a third-party addon, that would be the best way to insert into a database. If not, you can add PHP to your templates to achieve the same thing, we usually don’t recommend this because PHP in templates takes a small performance hit, but it may be easier for you to do. Let me know which you would like to do.
As for querying and displaying data, you can use the Query module which allows you to easily run a query and display the results in a template:
http://ellislab.com/expressionengine/user-guide/modules/query/index.html
Kevin
Does query work against an external MySQL databsae, or just EE’s?
Hi Larry,
You can query an external DB. You would just need to create a separate connection to that database with the CI database object. It’s pretty simple and there are some decent examples here: http://ellislab.com/codeigniter/user-guide/database/connecting.html
You may need to cover some bases regarding IP restriction, ports etc when connection to a database on a different server.
Best, Erik
Here are some additional suggestions I have received…
I would suggest first building a very simple codeigniter application to get familiar with the structure. EE uses a lot of CI libraries, including the database driver. Then when you get started on EE, take a look at the module development tutorial: http://ellislab.com/expressionengine/user-guide/development/module_tutorial.html Especially browse through the example code. You’ll see that it also creates its own tables. It’s a good idea to keep your data separate from ours, but you can still leverage EE in the process. Especially on the frontend you’ll see that building your own template tags is very, very simple. To process form data, take a look at creating action request, they can do the processing and then redirect the user to a result page: http://ellislab.com/expressionengine/user-guide/development/modules.html#install
I particulary like the idea of building one’s own EE tags to encapsulate MySQL calling logic. I’m still trying to get to this myself, but have been sidetracked a bit of late.
Thanks
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.