right syntax in scripts to reach the db in the default connection ?

lcollong

FabriKant d'applications web
Hi,

Migrating a site, my joomla was pointing on a new db while the fabrik connection was still on the old server. I thought it was a good solution at least not disturbing one, untill I realized that fabrik itself was using the data from the connection panel to reach its db but the php scripts used inside Fabrik (onAfterProcess, email condition, etc..) was connecting to the Joomla db.

Actually, all my scripts are using the common J framework to reach the database :
$db =& JFactory::getDBO();

But this may break the whole application if for a reason or another, one decide to put Fabrik's tables on another DB than the J! one.

So, what would be the universal syntax to be sure to use the "default" fabrik's connection while accessing the database from embedded php scripts ?

Would it be a good practice to declare a connection (default) for the "other than joomla" data and a another one to the J! base ? So the scripts will use the default connection to reach the "private data" and the other one to reach J! data such as #__users for example. Could both connections being the same most of the time without trouble ?

The idea is to be able to move the data on a separate MySQL server or db than the J! one just changing the default connection.
 
If your connection is is the same between sites, then you can use this:

http://fabrikar.com/forums/index.php?wiki/common-php-tasks/#use-alternate-fabrik-connection

Otherwise its a bit more complete to get the 'default' connection.

Could both connections being the same most of the time without trouble ?
Unless you really need to use different connections (e.g. you are connecting to a 3rd party system) its always best to use the same connection as the Joomla db, this is as we can not join across databases, so things like user elements can't show user names, etc.
 
Hi Rob,

I understand. However for some customers, for security reason or performance ones, it could be an advantage to not put the (critical ?) data tables inside the same db as the joomla ones (in case some backdoor or badly written extension erase them for example). The underlying idea was to be able to easily separate these things using "universal scripts"... but, indeed, we'll have to wait for cross connection DBjoin feature (if ever possible ?) ....

Thanks
 
Well I'd hope your Joomla db was secure ;) but I know what you mean. I honestly don't think cross db joins will be happening with Fabrik. However, I do understand the valid points you raise about 'universal scripts' and critical data
In that regard I'm doing some work on scoping out fabrik 4, which will be a different beast entirely, probably less feature rich in some ways to start with but we will be able to include reusable groups and I hope be able to connect to remote or local data sources.
 
Sounds promising indeed ! :). I'm sure Fabrik can play a yet much significant role in the professional area. These kind of consideration could be essential ones. We stay tuned !
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top