Registering Zend Database Adapter in Registry

后端 未结 9 2013
温柔的废话
温柔的废话 2020-12-23 00:07

I am looking to register a reference to the main Database Adapter in the Registry during Bootstrapping so it can be used elsewhere in my site (specifically the Authorisation

9条回答
  •  滥情空心
    2020-12-23 00:44

    My 2 cents...

    How to grab the default DB Adapter:

    From Bootstrap:

    getPluginResource('db');
    db = $dbResource->getDbAdapter();
    var_dump($db);
    ?>
    

    From a Controller there are two methods:

    getInvokeArg('bootstrap');
    $dbResource = $bootstrap->getPluginResource('db');
    $dbAdapter = $dbResource->getDbAdapter();
    var_dump($dbAdapter);
    
    // Method 2
    $dbAdapter = Zend_Db_Table::getDefaultAdapter();
    var_dump($dbAdapter);
    ?>
    

提交回复
热议问题