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
- Host: GitHub
- URL: https://github.com/heavenshell/php-silex-zf-db
- Owner: heavenshell
- License: bsd-3-clause
- Created: 2011-05-21T02:21:31.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2016-09-21T15:37:14.000Z (almost 10 years ago)
- Last Synced: 2025-04-24T03:13:18.467Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 19.5 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: license.txt
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