Bridge class to replicate the ease of Zend_Db in Zend Framework 2
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Db.php
LICENSE.txt
README.md

README.md

ZFBridge

Bridge class to replicate the ease of Zend_Db in Zend Framework 2.

In zf2 there's no fetchPairs, fetchCol or fetchOne methods from Db, this class tried to fill that gap with an easy approach.

LICENSE

The files in this archive are released under the New BSD license. You can find a copy of this license in LICENSE.txt.

USAGE

require_once "ZFBridge/Db.php";

// first of all we need the zf2 autoloader
$autoloader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true));
$autoloader->register();

// instancing db adapter
$adapter = new Zend\Db\Adapter\Adapter(array(
	'driver'       =>'Pdo_Mysql',
	'hostname'     => DB_READ_HOST,
	'username'     => DB_READ_USER,
	'password'     => DB_READ_PASS,
	'database'     => DB_READ_NAME,
	'characterset' => 'UTF8'
));

// replacing adapter with ZFBridge
$adapter = new \ZFBridge\Db($adapter);

// now we can use the old style fetchPairs etc
$adapter->fetchPairs("SELECT id, name FROM sampletable");