数据库查询可以使用原始sql,查询生成器和orm来触发。要了解laravel所有的 crud(创建,读取,更新,删除)操作,我们这里将用简单的学生管理系统来演示说明。
pdoexception in connector.php line 55:sqlstate[hy000] [1045] access denied for user 'homestead'@'localhost' (using password: yes)则需要配置 d:\laravel\.env 文件,如下:
d:\laravel>php artisan serve
数据库 − college
数据表 − student
列名
|
列数据类型
|
其它/备注 |
---|---|---|
id | int(11) | primary key | auto increment |
name | varchar(64) | 名字 |
age |
smallint(2)
|
年龄
|
create table `student` ( `id` int(10) unsigned not null auto_increment, `name` varchar(64) not null default '', `age` smallint(2) unsigned not null default '0', primary key (`id`) ) engine=myisam default charset=utf8;
s.no. |
记录和说明
|
---|---|
1 |
添加或插入记录
使用db::insert()方法插入记录
|
2 |
检索记录
配置数据库之后,使用 db::select() 方法检索记录
|
3 |
更新记录
使用db::update()方法更新记录
|
4 |
删除记录
使用db::delete()方法来删除记录
|