This class provides a genericized interface to the PHP PDO toolkit. It is a completely static class. More...
Static Public Member Functions | |
| static | init ($driver, $host, $database, $user=null, $password=null, $charset=null) |
| Initializes connection param class members. | |
| static | connect () |
| Create internal PDO object thus connecting to database using connection param class members (passed in from previous call to c_comdef_dbsingleton::init()) | |
| static | isConnected () |
| Returns whether internal PDO object is instantiated and thus connected. | |
| static | pdoInstance ($do_connect=false) |
| Provides access to internal PDO object in case this classes functionality is not enough. | |
| static | preparedQuery ($sql, $params=array(), $fetchKeyPair=false) |
| Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statements. | |
| static | preparedExec ($sql, $params=array()) |
| Wrapper for preparing and executing a PDOStatement that does not return a resultset e.g. INSERT or UPDATE SQL statements. | |
| static | lastInsertId () |
| Wrapper for PDO::lastInsertId() | |
Private Member Functions | |
| __construct () | |
| Private constructor (prevents direct creation of object) | |
Static Private Attributes | |
| static | $pdo = null |
| Internal PDO object. | |
| static | $driver = null |
| Connection database driver type param. | |
| static | $host = null |
| Connection host param. | |
| static | $database = null |
| Connection database param. | |
| static | $user = null |
| Connection user param. | |
| static | $password = null |
| Connection password param. | |
| static | $charset = null |
| Connection charset param. | |
| static | $fetchMode = PDO::FETCH_ASSOC |
| Default fetch mode for internal PDOStatements. | |
This class provides a genericized interface to the PHP PDO toolkit. It is a completely static class.
| c_comdef_dbsingleton::__construct | ( | ) | [private] |
Private constructor (prevents direct creation of object)
| static c_comdef_dbsingleton::connect | ( | ) | [static] |
Create internal PDO object thus connecting to database using connection param class members (passed in from previous call to c_comdef_dbsingleton::init())
Will destroy previous connection (if one exists) before reconnecting
| Exception | thrown if internal PDO object cannot be created e.g. wrong connection param(s) |
For security purposes, once we connect, we get rid of all the info, and a new init needs to be called.
| static c_comdef_dbsingleton::init | ( | $ | driver, |
| $ | host, | ||
| $ | database, | ||
| $ | user = null, |
||
| $ | password = null, |
||
| $ | charset = null |
||
| ) | [static] |
Initializes connection param class members.
Must be called BEFORE any attempts to connect to or query a database.
Will destroy previous connection (if one exists).
| driver | database server type (ex: 'mysql') |
| host | database server host |
| database | database name |
| user | user, optional |
| password | password, optional |
| charset | connection charset, optional |
Referenced by c_comdef_server::__construct(), DB_Connect_and_Upgrade(), and SetPageFive().
| static c_comdef_dbsingleton::isConnected | ( | ) | [static] |
Returns whether internal PDO object is instantiated and thus connected.
| static c_comdef_dbsingleton::lastInsertId | ( | ) | [static] |
Wrapper for PDO::lastInsertId()
| Exception | thrown if internal PDO object not instantiated |
| static c_comdef_dbsingleton::pdoInstance | ( | $ | do_connect = false | ) | [static] |
Provides access to internal PDO object in case this classes functionality is not enough.
| Exception | thrown if internal PDO object not instantiated |
| do_connect | Set this to true to force a connection if one does not yet exist. Default is false. |
Referenced by c_comdef_server::GetMeetings().
| static c_comdef_dbsingleton::preparedExec | ( | $ | sql, |
| $ | params = array() |
||
| ) | [static] |
Wrapper for preparing and executing a PDOStatement that does not return a resultset e.g. INSERT or UPDATE SQL statements.
See PDO documentation about prepared queries.
If there isn't already a database connection, it will "lazy load" the connection.
| Exception | thrown if internal PDO exception is thrown |
| sql | same as kind provided to PDO::prepare() |
| params | same as kind provided to PDO::prepare() |
Referenced by DB_Connect_and_Upgrade(), c_comdef_change::DeleteFromDB(), c_comdef_user::DeleteFromDB_NoRecord(), c_comdef_service_body::DeleteFromDB_NoRecord(), c_comdef_meeting::DeleteFromDB_NoRecord(), c_comdef_format::DeleteFromDB_NoRecord(), c_comdef_server::GetNewMeetingID(), SetPageFive(), c_comdef_user::UpdateToDB(), c_comdef_service_body::UpdateToDB(), c_comdef_meeting::UpdateToDB(), c_comdef_format::UpdateToDB(), and c_comdef_change::UpdateToDB().
| static c_comdef_dbsingleton::preparedQuery | ( | $ | sql, |
| $ | params = array(), |
||
| $ | fetchKeyPair = false |
||
| ) | [static] |
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statements.
Returns a multidimensional array depending on internal fetch mode setting (self::$fetchMode) See PDO documentation about prepared queries.
If there isn't already a database connection, it will "lazy load" the connection.
Fetching key pairs- when $fetchKeyPair is set to TRUE, it will force the returned array to be a one-dimensional array indexed on the first column in the query. Note- query may contain only two columns or an exception/error is thrown. See PDO::PDO::FETCH_KEY_PAIR for more details
| Exception | thrown if internal PDO exception is thrown |
| sql | same as kind provided to PDO::prepare() |
| params | same as kind provided to PDO::prepare() |
| fetchKeyPair | See description in method documentation |
Referenced by c_comdef_server::DoesMeetingExist(), c_comdef_meeting::GetAllMeetingKeys(), c_comdef_server::GetChangesFromSQL(), c_comdef_meeting::GetDataTableTemplate(), c_comdef_meeting::GetLongDataTableTemplate(), c_comdef_server::GetMeetingsFromSQL(), c_comdef_server::GetNewMeetingID(), c_comdef_server::GetOneFormat(), c_comdef_server::GetOneMeeting(), c_comdef_server::GetOneUser(), c_comdef_server::HuntForRadius(), c_comdef_server::IsFormatKeyUnique(), c_comdef_meeting::process_meeting_row(), c_comdef_server::ReadFormats(), c_comdef_server::ReadServiceBodies(), c_comdef_server::ReadServiceIDs(), c_comdef_server::ReadUsers(), c_comdef_user::RestoreFromDB(), c_comdef_service_body::RestoreFromDB(), c_comdef_meeting::RestoreFromDB(), c_comdef_format::RestoreFromDB(), c_comdef_change::RestoreFromDB(), c_comdef_user::UpdateToDB(), c_comdef_service_body::UpdateToDB(), and c_comdef_change::UpdateToDB().
c_comdef_dbsingleton::$charset = null [static, private] |
Connection charset param.
c_comdef_dbsingleton::$database = null [static, private] |
Connection database param.
c_comdef_dbsingleton::$driver = null [static, private] |
Connection database driver type param.
c_comdef_dbsingleton::$fetchMode = PDO::FETCH_ASSOC [static, private] |
Default fetch mode for internal PDOStatements.
c_comdef_dbsingleton::$host = null [static, private] |
Connection host param.
c_comdef_dbsingleton::$password = null [static, private] |
Connection password param.
c_comdef_dbsingleton::$pdo = null [static, private] |
Internal PDO object.
c_comdef_dbsingleton::$user = null [static, private] |
Connection user param.
1.7.4