Wrapper class for a MySQL PDO object. More...
Classes | |
| class | c_comdef_dbsingleton |
| This class provides a genericized interface to the PHP PDO toolkit. It is a completely static class. More... | |
Wrapper class for a MySQL PDO object.
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'); c_comdef_dbsingleton::connect(); $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: http://magshare.org/bmlt
BMLT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
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 GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this code. If not, see <http://www.gnu.org/licenses/>.
1.7.4