BMLT Root Server
Classes
c_comdef_dbsingleton.class.php File Reference

Wrapper class for a MySQL PDO object. More...

Go to the source code of this file.

Classes

class  c_comdef_dbsingleton
 This class provides a genericized interface to the PHP PDO toolkit. It is a completely static class. More...
 

Detailed Description

Wrapper class for a MySQL PDO object.

Version
1.0

Singleton class accessed via static methods

Based on code written by C. Drozdowski

Call to c_comdef_dbsingleton::init() to populate connection params must be made BEFORE any attempts to connect to or query a database.

c_comdef_dbsingleton::connect() may be called to explicitly connect to database (though not required- see next statement).

Both c_comdef_dbsingleton::preparedQuery() and c_comdef_dbsingleton::preparedExec() allow "lazy loading" of the connection. That is, they'll try to connect if there isn't already a connection made via c_comdef_dbsingleton:connect() method.

Typical usage:

c_comdef_dbsingleton::init('host', 'database', 'user', 'password');
$array = c_comdef_dbsingleton::preparedQuery('SELECT * FROM foo WHERE bar = :bar', array(':bar' => 'baz'));

Lazy loading usage:

c_comdef_dbsingleton::init('host', 'database', 'user', 'password');
$array = c_comdef_dbsingleton::preparedQuery('SELECT * FROM foo WHERE bar = :bar', array(':bar' => 'baz'));

Adding connection charset:

c_comdef_dbsingleton::init('host', 'database', 'user', 'password', 'latin1');

Internal instance of PDO is available via c_comdef_dbsingleton::pdoInstance() method.

See PDO documentation for more info about connections and prepared statements

This file is part of the Basic Meeting List Toolbox (BMLT).

Find out more at: https://bmlt.app

BMLT is free software: you can redistribute it and/or modify it under the terms of the MIT License.

BMLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MIT License for more details.

You should have received a copy of the MIT License along with this code. If not, see https://opensource.org/licenses/MIT.

Definition in file c_comdef_dbsingleton.class.php.