Guides > Database Connection Manager

Introducing The Database Connection Manager

The database connection manager is an excelent tool that can help you to manage database connections for your application / website. This component will store the connection details and conveniently initialize a PDO object to handle queries. This tool offers also full support for the PtQueryBuilder component, if specified as an option when adding a connection.

Main Features:

  • Handles multiple database connections
  • Full PDO support to handle queries
  • Can be used with the PtQueryBuilder class to prepare and execute queries
  • Uses the PtcDebug class to log all connections

Getting Started

To start managing your database connections with the connection manager, download the file PtcDb.php from the repository and add a new connection with your database details:

  1. require_once( 'PtcDb.php' );
  2.  
  3. PtcDb::add( array
  4. (
  5.     'user'    =>    'some user' ,
  6.     'pass'    =>    'some pass' ,
  7.     'db'      =>    'some database name'
  8. ) );
Now that we added a new connection, the component will initialize a PDO object, so that we can execute our queries.

Lets use our connection with the PtQueryBuilder class for example, to retrieve data from tables:
  1. // calling the query builder with the connection manager
  2. PtcDb::table( 'some_table' )
  3.     ->select( 'some_column as test' )
  4.     ->run( );
That should get you started with the Connection Manager component.
For a complete list of options and examples read the full user guide.


**If you like this class, help the project to grow by rating or writing a review at one of the following sites:

⇑Back to Top⇑