Welcome, Guest
Username: Password: Remember me

TOPIC: External database connection need help

External database connection need help 18 May 2014 08:54 #12448

  • rolandddiazcom
  • rolandddiazcom's Avatar
  • Offline
  • Junior Member
  • Website Developer
  • Posts: 21
  • Karma: 0
How do i use the external database connection or multiple database connection to query outside joomla database tables and show it in the j-cook grid layout?

my goal is to use external or existing tables not connected in main joomla database, but to show the results in j-cook builder.

Example view 1 :

external database with tables to query it and display in the view 1

another continuous external database connection

example : view 2

external database connection another database name with tables


Now how do i insert it in the j-cook pro generated model scripts?

currently i only see the $query from table generated in j-cook but how do i insert the external database

Below are the external db configuration that i need to be placed in j-cook

<?php
$db = JFactory::getDbo();
?>

<?php
$option = array(); //prevent problems

$option = 'mysql'; // Database driver name
$option = 'db.myhost.com'; // Database host name
$option = 'fredbloggs'; // User for database authentication
$option = 's9(39s£h[%dkFd'; // Password for database authentication
$option = 'bigdatabase'; // Database name
$option = 'abc_'; // Database prefix (may be empty)

$db = JDatabase::getInstance( $option );
?>

public function __construct($config = array())
{
parent::__construct($config);

$option = array(); //prevent problems

$option = 'mysql'; // Database driver name
$option = 'localhost'; // Database host name
$option = 'myusername'; // User for database authentication
$option = 'saltedpassword'; // Password for database authentication
$option = 'db_extern'; // Database name
$option = ''; // Database prefix (may be empty)

$db = JDatabase::getInstance( $option );
parent::setDbo($db);
}

this code must be eliminated if needed but only the needed for j-cook should be used.

Anybody help ?
The administrator has disabled public write access.

External database connection need help 07 Jul 2014 13:00 #12508

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Create the views in j-cook (back-end and/or front-end)
This including all the field and such which you want to show from the external database

Then use the fork system to override the model.
I.E. override getItems() or prepareQuery() depending on your needs to get the data from your external source.

Regards.
The administrator has disabled public write access.
The following user(s) said Thank You: admin

External database connection need help 26 Jul 2014 11:48 #12544

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Hi DIAZ,

You code in the constructor model is wrong, the array initialization is not properly coded.
You must define such as :
$option = array(
  'key' => 'value'
  '...' => '...'
)

Then it will work.
I do not have the correct code in my hands, you can check the joomla documentation. But I remember that you simply have to write it in the model constructor, and so your SQL statements will be sent to the other database correctly.
I think you need to edit the table file as well to change the table name.

Hope it helps.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.080 seconds

Get Started