asgard / db
v0.3.1
2016-05-13 11:31 UTC
Requires
- php: >=5.5.9
- asgard/common: ~0.3.0
Requires (Dev)
- doctrine/dbal: ^2.0
Suggests
- doctrine/dbal: ^2.0
This package is not auto-updated.
Last update: 2024-09-20 06:59:58 UTC
README
#数据库
DB包允许您操作数据库,构建SQL查询,并使用Schema操作表结构。
##安装 如果您正在处理Asgard项目,您不需要安装此库,因为它已经是标准库的一部分。
composer require asgard/db 0.*
##DB
用于连接数据库并执行SQL查询。 查看文档。
$rows = $db->query('SELECT * FROM news ORDER BY id DESC')->all();
##DAL
以面向对象的方式构建SQL查询。 查看文档。
$rows = $db-dal->from('news')->orderBy('id DESC')->all();
##Schema
构建、修改和删除表。 查看文档。
schema->table('news', function($table) {
$table->addColumn('id', 'integer', [
'length' => 11,
'autoincrement' => true,
]);
$table->addColumn('created_at', 'datetime', [
]);
$table->addColumn('updated_at', 'datetime', [
]);
$table->addColumn('title', 'string', [
'length' => '255',
]);
$table->setPrimaryKey(['id']);
});
##命令
###贡献
请将所有问题和拉取请求提交到 asgardphp/asgard 仓库。
许可证
Asgard框架是开源软件,在MIT许可证下授权。