DB facade实现CURD】的更多相关文章

public function test1() { //新增数据: /* $bool=DB::insert('insert into student(name,age) VALUES (?,?)', ['imooc',18] ); var_dump($bool);*/ //更新数据: /* $bool=DB::update('update student set age=? where name=?', [20, 'sean']); var_dump($bool);*/ //查询数据表中的数据:…
数据表 CREATE TABLE IF NOT EXISTS students( `id` INT AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '姓名', `age` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '年龄', `sex` TINYINT UNSIGNED NOT NULL DEFAULT 10 COMMENT '性别', `crea…
<?php namespace App\Http\Controllers; use App\Student; use Illuminate\Support\Facades\DB; class StudentController extends Controller { //DB facade原始SQL语句 public function test1() { $students = DB::select('select * from student'); //var_dump($students)…
/* $students=DB::select("select * from student"); var_dump($students);*/ //新增数据: /*$bool=DB::insert('insert into student(name,age) values(?,?)',['imooc',18]); var_dump($bool);*/ //更新数据: /*$num = DB::update('update student set age=? where name=?'…
连接数据库 一.Outline 三种操作数据库的方式. 二.Facade(外观)模式 Ref: 解读Laravel,看PHP如何实现Facade? Facade本质上是一个“把工作推给别人做的”的类. Facade存在的价值,可以从服务容器谈起.服务容器,可见我的另一篇博文,地址:http://www.cnblogs.com/sweng/p/6430374.html 举个例子,不知道大家以前写代码有没有过obj->method(arg1,arg2)->func(arg3,arg4);的体验.学…
session中set方法使用 Session::set('user.username.age','18')嵌套使用得出$user = ['username'=>['age'=>18]]; 取出也可以这样Session::get('user.username.age'); 轻松学会Laravel-基础篇 5-4 使用查询构造器查询数据 DB::table(表名)->chunk(每组数量,function($data){ dd($data); if(条件) return false//只查…
laravel中提供DB facade(原始查找).查询构造器.Eloquent ORM三种操作数据库方式 1.连接数据库 .env 数据库配置 DB_HOST=localhost dbhost DB_DATABASE=laravel dbname DB_USERNAME=root username DB_PASSWORD=root password 2.使用DB facade实现CURD (1) 新建路由 Route::get('city', 'cityController@index');…
一.Laravel核心目录文件介绍 app:程序的核心代码和业务逻辑代码,其中的Http目录是我们业务逻辑的存放点 bootstrap:包含框架启动的和自动加载文件 config:包含所有程序中的配置文件,比如:cache.php(缓存)database.php(数据库).queue.php(队列)等 database:包括数据库填充和迁移文件 public:程序入口和静态文件,比如之后的CSS .JS.IMG 等 resources:包含视图和原始系统文件 storage:包含编译后的文件 t…
LTS : long time support. download url : http://www.golaravel.com/download/ 第一篇 目录介绍: ​ resource:包含了原始的资源文件和视图文件. ​ storage:包含编译好了的缓存文件以及基于文件产生的log和session等等. ​ vendor:包含comporsor下载的依赖模块. 路由 路由简介 ​ get, post, put, patch, delete 基本路由 Route::get('michae…
一.laravel简介 laravel是一套优雅简介的PHP开发框架,受欢迎程度非常之高,功能强大,工具齐全:以下是本人在学习过程中记录的laravel比较基础的资料,权当学习笔记,请大神们多多指教 二.版本选择 本篇学习笔记以laravel5.2.15版本为框架的版本基础:更多版本请移步https://www.golaravel.com/ 三.laravel下载安装以及开发环境搭建 (一):环境搭建 由于laravel使用较多的php新特性,所以新版本的laravel对PHP的版本要求比较高,…