<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Configuring a Connection</title><link>https://sourceforge.net/p/dbtrek/wiki/Configuring%2520a%2520Connection/</link><description>Recent changes to Configuring a Connection</description><atom:link href="https://sourceforge.net/p/dbtrek/wiki/Configuring%20a%20Connection/feed" rel="self"/><language>en</language><lastBuildDate>Mon, 28 May 2012 22:34:37 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/dbtrek/wiki/Configuring%20a%20Connection/feed" rel="self" type="application/rss+xml"/><item><title>WikiPage Configuring a Connection modified by DataExplore</title><link>https://sourceforge.net/p/dbtrek/wiki/Configuring%2520a%2520Connection/</link><description>Data Connections are set up in the classes folder.  Each connection to a database for a particular type of data source (e.g. mySQL, Access) is stored in the class for that type.  

To set up new mySQL connections, for example, open the /classes/mySqlConn.class.php file and add each separate database connection as a function:

example: 

function test() {
    $this-&gt;db = new mysqli('hostname',
                            'user',
                            'password',
                            'mydatabase'
                            );

}

When the test() method is called from the child class (mySqlObject.class.php), a connection to the database will be made and stored in the class property $this-&gt;db.

This structure will allow you to have several connections configured and then just call on them when instantiating the child class with the second parameter.

$obj = new mySqlObject('table_name','connection_name');

The function can be named anything you want it to be, as long as it is easy for you to remember.  If you want to make a connection the default for that data source type, then make a call to it in the cnDefault() function for that class.

function cnDefault() {
    $this-&gt;test();
}

This will allow you make the connection to test without specifying the second parameter in a child class instantiation statement.

$obj = new mySqlObject('table_name');

Custom connection types can be created by the user by creating a class for it.  All connection classes implement the dbConn interface, since the cnDefault() method is a requirement.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">DataExplore</dc:creator><pubDate>Mon, 28 May 2012 22:34:37 -0000</pubDate><guid>https://sourceforge.net9483c9e178853d6c5a4117ee84c067aa8ebef425</guid></item></channel></rss>