fuel_nav() and db source

edited April 2014 in Share
Hi again,

I am creating a site that uses 2 databases (the secondary db "belongs to" another fuel installation on the same server). I've configured this OK, and one controller in particular uses models that retrieve data from the secondary database. That's working OK too.

What's a bit odd is that the views for this controller have a fuel_nav() in one of the view "blocks", and that returns the navigation for the other installation (that is, from the secondary db). So only models loaded in the controller have an alternate dsn (ultimately), but fuel_nav() is also picking this up somehow. Is there anything I can do to force it to use the intended database?


  • edited 1:59AM
    So was the navigation in the CMS? If so, it may be using the last connection that was loaded. Perhaps try loading the database again right before calling fuel_nav using:
    $this->load->database($dsn, TRUE, TRUE);
    Where $dsn is your database connection array information (also found in the database.php config file).
  • edited 1:59AM
    Yeh good point - also I remember leaving pconnect ON, which may not help.

    Incidentally, I extended the models that use the 2nd db from MY_Model, and set the $dsn value inside the extended model's constructor - is that best practice?
  • edited 1:59AM
    OK that worked - but setting pconnect to FALSE has the same effect, interestingly.

Sign In or Register to comment.