Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

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

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 ?

Please Log in or Create an account to join the conversation.

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

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 following user(s) said Thank You: admin

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.056 seconds

I'm playing around with the new mvc and the FORK feature is FANTASTIC!!! it's saving me a lot of time! you are doing a very good job!!

Tomaselli (Forum)  

Get Started