psamatt / spot-service-provider
Silex 的 Spot (DataMapper ORM) 服务提供商
1.0.0
2013-09-08 17:19 UTC
Requires
- php: >=5.3.2
- silex/silex: 1.*
- vlucas/spot: dev-master
This package is not auto-updated.
Last update: 2024-09-23 13:57:58 UTC
README
Spot 的 ServiceProvider,用于 Silex
Spot 是一个为 PHP5.3+ 编写的轻量级 DataMapper,易于使用,非常适合在 Silex 中构建的小型应用程序
用法
传递 DSN 字符串
为了连接到您的 MySQL 数据库,将有效的 DSN 字符串传递给提供者
$app->register( new Psamatt\Silex\SpotServiceProvider('mysql://username:password@localhost/db_name') );
在您的 index.php 中,您可以使用以下行与 Spot 交互
// Find all the posts from the database where the status is 1 $app['spot']->all('Entity\Post', array('status' => 1)); // Find one post where the title is Test Post $app['spot']->first('Entity\Post', array('title' => "Test Post"));
有关如何使用 Spot 的更多信息,请参阅 github 仓库页面