Forums

Pointing DB Record Loader to another database

gdearing 11 Oct, 2011
I am new to Chronoforms, but believe I have most of the basics down. My issue is that I want to populate a form with data from a MySQl database on the same server but which is not the Joomla database. On the DB Save event, there is the advanced tab where I can point successfully to the non-Joomla database, but I cannot find a similar capability in the DB Record Loader event. It only shows the Joomla DB tables in the drop down and I cannot find where to supply the information for the second database as in the DB Save Event.

I am using Joomla! 1.7.1 Stable [ Ember ] 26-Sep-2011 14:00 GMT and Chronoforms_J1.6_V4_RC2.0.

Any help will be appreciated.
GreyHead 12 Oct, 2011
Hi gdearing,

You can do this using a Custom Code action. The code to connect to a second database is in this tutorial doc

Bob
gdearing 14 Oct, 2011
Thanks for the feedback. I had already seen that document and played with custom code. I added the custom code to the top of the On Load event with no problem.

What I cannot figure out is how to use this second db connection in the DB Record Loader section. When I hit the drop down on the table name, I only get the tables in the Joomla database those not in my second database.

Here are the events I have on the form

1. Custom Code Action- contains code similar to the example code below
<?php
$options = array(
'host' => 'xxx',
'user' => 'xxx',
'password' => 'xxx',
'database' => 'xxx',
'prefix' = 'xxx',
'select' => true
);
$db2 =& new JDatabaseMySQL($options);
?>

2 DB Record Loader Action-
On Record Found- I fill it out as I have successfully for forms that access Joomla tables, but cannot select the table name since tables for the database referenced in the custom code are not included.

3. Show HTML Action-

4. On Submit Event- DB Save- Use the advanced tab to point to the second database. I use the same model name as for the DB Record Loader Action.

The result when I run this is that I can submit and save records in the second database just fine, but cannot retrieve a record to be displayed since I cannot select the table to get the record from in the Record Loader Action. In your article, you indicate I need to have something like $db2->setQuery($query); I just cannot figure out where to put such code in the stack of events/actions and how I would be able to bring up specific records by passing a token to the form such as http://www.eminders.biz/index.php?option=com_chronoforms&chronoform=hours_form&token=2
This topic is locked and no more replies can be posted.