PostNuke: A Flexible Open Source Content Management System
home | forum | international support | contact us

Support Forum

Start ::  PostNuke 0.7 Support ::  Tutorials and Solutions ::  Many databse with postnuke

Moderated by: Support Team

Bottom
Many databse with postnuke

  • Link to this postingPosted: 20.03.2008, 11:24
    Profile
    DJUS
    rank:
    pnFreshman pnFreshman
    registered:
     March 2008
    Status:
    offline
    last visit:
    29.04.08
    Posts:
    15
    Hello everybody!
    I discoversd PostNuke two weeks ago and started to understand how does it work it's really great! icon_smile
    I have a porblem with database, actually i installed PostNuke with a default database on localhost and now i wan't PostNuke
    to get connected in the same time to another database located on a server! The aim is to put the inforamtion data on a database located on the network and the PN databse (login, user, admin ...) on localhost! I made changes on the config file in the PostNuke installation directory but nothing happened PN continue to use only my local host database!
    Can you help me please ? Thank you
  • Link to this postingPosted: 20.03.2008, 13:28
    Profile Homepage
    espaan
    rank:
    pnHelper pnHelper
    registered:
     August 2003
    Status:
    offline
    last visit:
    09.05.08
    Posts:
    237
    Hi, welcome to PostNuke. AFAIK multiple databases is not supported. There was a post in the forums some weeks ago about accessing multiple databases. You might search a little.



    edited by: espaan, Mar 20, 2008 - 02:28 PM
  • Link to this postingPosted: 20.03.2008, 13:54
    Profile Homepage
    nestormateo
    rank:
    pnProfessional pnProfessional
    registered:
     September 2006
    Status:
    online
    Posts:
    916
    Well, there's a way to work with multiple databases using the 'DBConnectionStack', search a little in the forum that keyword and you'll find the thread where that was discussed.
    icon_wink

    -----
    - Mateo T. -
    Mis principios... son mis fines
  • Link to this postingPosted: 20.03.2008, 15:13
    Profile Homepage
    kaffeeringe.de
    rank:
    pnProfessional pnProfessional
    registered:
     September 2002
    Status:
    offline
    last visit:
    11.05.08
    Posts:
    745
    You are both right:
    1. PostNuke .8 supports connections to various databases via DBConnectionStack.
    But:
    2. AFAIK it doesn't switch back and forth automatically. So if you for example put the user DB onto the second server it won't automatically fetch them there. IIRC you can only program modules that fetch information from several DBs if you explicitly say which data can be fetched where.

    -----
    best regards from Kiel, sailing city

    Steffen Voß

    Member of the PostNuke Steering Committee
    Visit: Kaffeeringe.de - Internet & Kreativität
  • Link to this postingPosted: 20.03.2008, 15:45
    Profile
    DJUS
    rank:
    pnFreshman pnFreshman
    registered:
     March 2008
    Status:
    offline
    last visit:
    29.04.08
    Posts:
    15
    Thank you guys for your quick answers!

    I loocked up for DBConnectionStack , it's a stack which allows to handle multiple data base connexion; in fact i used the method 'pop' which pops the current active connection off the stack and retuen the newly active connexion. So here is what i have done:

    if (!SecurityUtil::checkPermission('xxx::', '::', ACCESS_OVERVIEW))
    {
    return LogUtil::registerPermissionError();
    }
    $pnRender = pnRender::getInstance('xxx');
    >>>>>> DBConnectionStack::popConnection();
    $pntable = pnDBGetTables();
    $column = $pntable['produits_column'];
    $sessionId = session_id();

    Fatal error: Call to a member function Execute() on a non-object in C:\....\PostNuke\compile\includes\pnobjlib\DBUtil.class.php on line 89

    Fatal error: Class 'SafeHTML' not found in C:\..\PostNuke\compile\system\SecurityCenter\pnuserapi.php on line 473

    Yes, i am a beginner in PostNuke icon_smile
    Do you have any hint to give me ? Thank you icon_wink
  • Link to this postingPosted: 21.03.2008, 10:18
    Profile Homepage
    rgasch
    rank:
    Steering Committee Steering Committee
    registered:
     January 2003
    Status:
    offline
    last visit:
    01.05.08
    Posts:
    550
    Hi,

    see the following threads for some more info. Then come back here if you still have questions:

    http://community.postnuke...ht-ConnectionStack.htm
    and
    http://community.postnuke...ht-ConnectionStack.htm

    Please note that to access a new database you should use "pushConnection" and then use "popConnection" to remove this connection once you're done accessing the external database.

    Greetings
    R
  • Link to this postingPosted: 25.03.2008, 09:07
    Profile
    DJUS
    rank:
    pnFreshman pnFreshman
    registered:
     March 2008
    Status:
    offline
    last visit:
    29.04.08
    Posts:
    15
    Hello,
    I made some modification in my code and i succeed to get connected to both database in the same time!
    The problem came also from the fact that i had to encode the user name end the password using the base64_encode function of the config file as the following:
    $PNConfig['DBInfo']['external2']['dbuname'] = base64_encode("username");
    $PNConfig['DBInfo']['external2']['dbpass'] = base64_encode("password");

    The code modification is the followig:


    $sessionId = session_id();
    $SQL = "SELECT `*******` ";
    DBConnectionStack::pushConnection('external2');
    $result = DBUtil::executeSQL($SQL);
    DBConnectionStack::popConnection();

    The code is working but i was wondering if i can make a function that can keep the connexion in the stack of DBConnexionStack
    alive without having to pass by the whole class and the init function at each time? Thing which can cause a loss of performance
    In fact i was wondering if maybe i can write a new class (SetActiveconnexion()) for example to put into the core of PostNuke
    which allows to keep the two database connexion alive without having to use push and pop from and into the stack at each time ? What do you think ? Is it possible ?
  • Link to this postingPosted: 25.03.2008, 10:55
    Profile Homepage
    rgasch
    rank:
    Steering Committee Steering Committee
    registered:
     January 2003
    Status:
    offline
    last visit:
    01.05.08
    Posts:
    550
    While what you are proposing is certainly possible, I would suggest that you modify your code so that *all* access to the 2nd database is done in 1 go. With proper logical design, it should not be necessary to use push/pop more than once for a particular action.

    If you think that my reasoning is not correct, please come back here and tell me why you think this is the case and what you would propose to do about this.

    The reason I'm not overly excited about adding a setActiveConnection() function is that it could complicate the an otherwise clean and simple design. It might however be an idea to modify popConnection() to keep the removed connection in a local cache so that it can easily be re-added to the stack if needed. Please consider these issues and then report back.

    Greetings
    R

Start ::  PostNuke 0.7 Support ::  Tutorials and Solutions ::  Many databse with postnuke

Main Menu

Extensions Database

Documentation

Development

Login





 


 Log in Problems?
 New User? Sign Up!

Donate to PostNuke