<?php namespace DDDBL; $objQueue = Singleton::getInstance('\\DDDBL\\Queue'); ############################# ### db-connection handler ### ############################# # get (or first establish) connection to database # and store the DataObject of the connection in the Queue-State $cloStoreDBConnection = function (\DDDBL\Queue $objQueue, array $arrParameter) { if (!isConnected()) { connect(); } $objQueue->getState()->update(array('DB' => getDBDataObject())); }; $objQueue->addHandler(QUEUE_GET_DB_CONNECTION_POSITION, $cloStoreDBConnection); ############################### ### query-definition-loader ### ############################### # get the DataObject of the query and store it in the queue $cloGetQuery = function (\DDDBL\Queue $objQueue, array $arrParameter) { $objDataObjectPool = new DataObjectPool('Query-Definition'); # get the first entry of the parameter-list; this is the query-alias $strAlias = array_shift($arrParameter); if (empty($strAlias) || !is_string($strAlias)) { throw new \Exception('no query-alias defined!'); } if (!$objDataObjectPool->exists($strAlias)) { throw new \Exception("given query alias is unknown: {$strAlias}"); }
/** * @throws UnexpectedParameterTypeException - if the given parameter is not a string * * @returns (boolean) false, if no connection is established * * check if a connection to the database is established. if so, * the given parameter is used, as method to call at the * PDO object. the result of the call is returned * **/ function mapMethod($strMethod) { if (!is_string($strMethod)) { throw new UnexpectedParameterTypeException('string', $strMethod); } if (!isConnected()) { return false; } $objDB = getDBDataObject(); $objPDO = $objDB->get('PDO'); return $objPDO->{$strMethod}(); }