Welcome,
Guest
.
Please
login
or
register
.
Did you miss your
activation email
?
News:
Bug reports and fixes
.
Home
Help
Login
Register
Elxis CMS Forum
»
Support
»
Database
»
Need Help: How to make two/more database connection ???
« previous
next »
Print
Pages: [
1
]
Author
Topic: Need Help: How to make two/more database connection ??? (Read 10474 times)
muharihar
Jr. Member
Posts: 77
muharihar
Need Help: How to make two/more database connection ???
«
on:
February 05, 2009, 12:23:30 »
we development an information system with elxis cms (back-end).
it's need two or more database connection (one type or multiple database) for processing data from multiple database, for example:
------------------------------------------------------
start code....
dbcon1 -> elxis database connection for oracle (1).
dbcon1->setQuery('select * from oracle_table');
data1 = dbcon1->loadObjectList();
dbcon2 -> elxis database connection for oracle (2).
dbcon2->setQuery('select * from oracle_table');
data2 = dbcon2->loadObjectList();
dbcon3 -> elxis database connection for mysql;
dbcon3->setQuery('select * from mysql_table');
data3 = dbcon3->loadObjectList();
code for processing data from 3 different database...
-----------------------------------------------------------
anyone can help me by give an example code?
thanks...
Note:
preview for my information system with elxis (for intranet access only):
http://mhs.infoterkini.com/new/index.php?option=com_content&view=article&id=125:sak-w3-version-progress-roadmap20091&catid=59:software-goverment&Itemid=89
«
Last Edit: February 05, 2009, 12:44:41 by muharihar
»
Logged
how technology and nature stand together!
---------------------------------------------------
www.OmahIjo.net
datahell
Elxis Team
Hero Member
Posts: 10356
Re: Need Help: How to make two/more database connection ???
«
Reply #1 on:
February 05, 2009, 14:13:43 »
Do you develop an elxis fork?
«
Last Edit: February 05, 2009, 14:25:47 by datahell
»
Logged
Elxis Team
|
Is Open Source
|
IOS Rentals | IOS AERO
muharihar
Jr. Member
Posts: 77
muharihar
Re: Need Help: How to make two/more database connection ???
«
Reply #2 on:
February 05, 2009, 15:29:34 »
I use elxis as a framework to develop "Elxis Information System" (components, moduls, templates etc) and
i don't remove the elxis copyrigth
from "Elxis Information System".
The preview on my blog is to show the development progess to my client.
The preview link on this forum only to show my software to the forum, it's use oracle as the database.
The preview is about EIS (Eksekutif Information System, in indonesia called SIE (Sistem Informasi Eksekutif)) build with elxis as the core/framework.
The EIS future use default Elxis future ( like Blog, Polling, etc). And the unique EIS future is build by us (like graphical reporting).
In the EIS, we need more than one database connections. for example:
Connection 1 : The elxis default connection -> access to ELXIS_ORACLE_DATABASE.
Connection 2 : The EIS connection -> access to EIS_ORACLE_DATABASE.
Connection 3 : The EIS connection 2 -> access to EIS_MYSQL_DATABASE.
so.... would you like to help me... how to make more than one database connection?
thanks...
«
Last Edit: February 05, 2009, 15:51:05 by muharihar
»
Logged
how technology and nature stand together!
---------------------------------------------------
www.OmahIjo.net
datahell
Elxis Team
Hero Member
Posts: 10356
Re: Need Help: How to make two/more database connection ???
«
Reply #3 on:
February 05, 2009, 18:49:57 »
As long as you keep elxis copyright and logo and you respect Elxis license and our work you are welcome here and I will help you. If I see that you are going to create an illegal fork you will be banned.
In Elxis it is very easy to open as many connections to the database or to different databases, even of different type, you like.
Here is the general way to do it:
Create a new connection to the same or to other database:
$database2 = new database('host', 'user', 'pass', 'database name', 'prefix', 'driver');
Then you can use this connection via the $database2 object as usual. Example:
$database2->setQuery("SELECT *.....");
$database2->loadRow();
You can also use directly the underlying ADOdb library via the "_resource" property. Example:
$database2->_resource->databaseType;
Here is a sample new connection to Oracle:
$ocidb = new database('localhost', 'sample', 'pass', 'sample', 'elx_', 'oci8');
$ocidb->setQuery("SELECT COUNT(bid) FROM #__banners");
$number_of_banners = intval($ocidb->loadResult());
Default Elxis connection ($database) can co-exist with the new database instances/connections.
If your second database is not Elxis' then you don't have to use the Elxis' database class. You can connect, if you like, to the second db directly with ADOdb. Example:
$acon = NewADOConnection('oci8');
$acon->NLS_DATE_FORMAT = 'RRRR-MM-DD HH24:MI:SS';
$acon->charSet = 'AL32UTF8';
$acon->Execute("ALTER SESSION SET NLS_DATE_FORMAT='RRRR-MM-DD HH24:MI:SS'");
$acon->PConnect('host', 'user', 'pass');
$acon->Execute("oracle sql");
«
Last Edit: February 05, 2009, 19:03:44 by datahell
»
Logged
Elxis Team
|
Is Open Source
|
IOS Rentals | IOS AERO
muharihar
Jr. Member
Posts: 77
muharihar
Re: Need Help: How to make two/more database connection ???
«
Reply #4 on:
February 06, 2009, 03:54:01 »
Thanks datahell...
Logged
how technology and nature stand together!
---------------------------------------------------
www.OmahIjo.net
Print
Pages: [
1
]
« previous
next »
Elxis CMS Forum
»
Support
»
Database
»
Need Help: How to make two/more database connection ???