Vulnero

Seamless WordPress and Zend Framework Integration

Most applications require a database connection in order to store persistent data. WordPress already has a connection to MySQL for storing its setup and content. Vulnero bootstraps a Zend_Db_Adapter_Mysql database adapter through Zend_Db's factory method to the same database.

If for whatever reason this connection can't be established, an Sqlite database will be created as a fallback in Vulnero's root directory called sqlite.db.

You can access the database adapter from your bootstrap. For example, to access it from a controller:

public function visitAction()
{
    $db = $this->getInvokeArg('bootstrap')
               ->bootstrap('db')
               ->getResource('db');
    $pdo = $db->getDbh();

    $stmt = $pdo->query('SELECT * FROM wp_options');
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        echo $row['option_name'] . ':' . $row['option_value'];
    }
}

You can override the database connection that's used (or disable it entirely) by adding your own _initDb method to your application/Bootstrap.php's Bootstrap class.

/* vim application/Bootstrap.php */
...

protected function _initDb()
{
    $db = Zend_Db::factory('Pdo_Mssql', array(
        'slow-mode' => 'very-slow',
        'crashes'   => true
    ));
    return $db;
}