An open API service indexing awesome lists of open source software.

https://github.com/heavenshell/php-silex-zf-db

Silex Zend_Db extension
https://github.com/heavenshell/php-silex-zf-db

Last synced: about 1 year ago
JSON representation

Silex Zend_Db extension

Awesome Lists containing this project

README

          

Silex Zend_Db extension.

This extension is for the Silex microframework enables use Zend Framework's Zend_Db.

register(new \Zf1\DbExtension(), array(
'zend.class_path' => $zendpath,
'zend.db.adapter' => 'Pdo_Sqlite',
'zend.db.options' => array(
'dbname' => __DIR__ . '/test.db',
)
));

$app->before(function() use ($app) {
$db = $app['zend.db']();
$conn = $db->getConnection();
$app['zend.db.connection'] = $conn;

// When you use Model class, add to namespace.
// If you not using namespace, use registerPrefix() instead.
$app['autoloader']->registerNamespace('Model', __DIR__);
});

$app->get('/create', function () use ($app) {
$db = $app['zend.db']();
$db->insert(
'entries', array('title' => 'test_title', 'text' => 'test_text')
);
$table = new \Model\Entries();
$row = $table->fetchAll();
return json_encode($row->toArray());
});

Set Zend Framework1 library to your include_path
- Running examples
Add SetEnv ZF_PATH /Path/To/include_path to .htaccess
- Running tests
export ZF_PATH=/Path/To/include_path

See more detail http://framework.zend.com/manual/en/zend.db.html