Jump to content


Photo
- - - - -

RTE edit test


  • Please log in to reply
No replies to this topic

#1 Michael

Michael

    Administrator

  • Management
  • 3,467 posts
  • Location:Columbus, OH
  • IP.Board Version:3.4
Contributor

Posted 17 January 2011 - 11:15 PM

This is a trick you can use in your IP.Board code, and it also can come in handy for IP.Content as well; it was working with a client on their IP.Content page that I found this code.

The IP.Board database object (usually the $this->DB object in the IP.Board code) is set up by default to connect to the database that has its info defined in your conf_global.php file. You can use the IP.Board framework to quickly create a secondary database connection that has access to all of the same functions. This comes in very handy if you ever need to connect to a database external to your IP.Board install to pull in info from it.

Here's the basic code for it:

/* Set up our alternate database object */
ips_DBRegistry::setDB( 'mysql', 'db2', array( 'sql_database' =>  '***', 'sql_user' => '***', 'sql_pass' => '***', 'sql_host' =>  '***', 'sql_charset' => '***', 'sql_tbl_prefix' => '***' ) );
$DB2 = $this->registry->DB( 'db2' );
Just fill in that info related to the database on the top line, and $DB2 now is a database object that connects to this secondary database.

If your code is inside a class, you can also adapt this code to create a $this->DB2 object, it's best to do that in the class's constructor. That way, the database object exists throughout the class.
My Stuff: My Forum · My Resources · My Tutorials
Contact Me: Email · Facebook · Twitter · Google+
Follow Invision Focus: On Facebook · On Twitter




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users