Marmot Manual

Chapter 18. Database DataSources

Table of Contents

Database connection types
Database basics
Detecting errors
Transaction support
Placeholder replacement
Executing statements
DBMS specific features

Databases are critical to almost every application. However, each DBMS offers different features and their drivers are usually not consistent- especially in PHP. In order to provide more a consistent interface, as well as some missing features, Marmot incorporates a object oriented database implementation that is flexible and extensible.

It is important to understand that different DBMSs offer drastically different features. The goal of Marmot's database objects is to provide a consistent set of methods while allowing access to specific features of the DBMS.

Database connection types

Much of the overhead for accessing a database is the initial connection. Many web environments solve this problem by creating persistent connections to the database. A persistent connection does not disconnect when the current process ends. The same connection will then be reused the next time an identical connection is requested. By default, database connections are created as persistent.

You can alter the default behavior to force a new connection by supplying the optional second parameter 'new' to the DataSource object constructor.

$ds = new MU_DataSource('data_source_name', 'new');