コード例 #1
0
### format the query result ###
###############################
# if a result-handler for the query is configured, call it
$cloFormatQueryResult = function (\DDDBL\Queue $objQueue, array $arrParameter) {
    $objQuery = $objQueue->getState()->get('QUERY');
    if (!$objQuery->exists('HANDLER')) {
        return;
    }
    # get the handler and its config
    $strHandlerConfig = $objQuery->get('HANDLER');
    $arrHandlerConfig = preg_split('/\\s+/', $strHandlerConfig);
    $strHandler = array_shift($arrHandlerConfig);
    # remove handler-name from config
    $strHandlerConfig = trim(str_replace($strHandler, '', $strHandlerConfig));
    $objDataObjectPool = new DataObjectPool('Result-Handler');
    if (!$objDataObjectPool->exists($strHandler)) {
        throw new \Exception("unknown result-handler: {$strHandler}");
    }
    $objHandler = $objDataObjectPool->get($strHandler);
    $cloHandler = $objHandler->get('HANDLER');
    $cloHandler($objQueue, $strHandlerConfig);
};
$objQueue->addHandler(QUEUE_FORMAT_RESULT_POSITION, $cloFormatQueryResult);
####################
### close cursor ###
####################
# closing the cursor of the PDOStatement. this will free
# the result and enable the connection to execute the next query
$cloCloseCursor = function (\DDDBL\Queue $objQueue, array $arrParameter) {
    $objQueryResult = $objQueue->getState()->get('PDOStatement');
    $objQueryResult->closeCursor();