1. 安装好之后,把根目录中的.env.example改成.env (并且可以配置数据库信息),访问就好啦!
控制器位置在app/http/controller目录下 模型层中安装的时候没有统一目录,是根据自己的习惯建个模型层就ok啦!或者在app目录下比如:User.php 视图层位于resources目录下
路由位于route目录下
下面为一些数据库操作的方法
<?php namespace App\Http\Controllers; use App\Http\Controllers; use Illuminate\Support\Facades\DB; use App\Http\model\Test; class IndexController extends Controller { /** * 显示首页。 * * @return Response */ public function index(){ //查询数据 $Test = new Test(); $list = $Test->readTest(); //dump($list);exit; //添加 //$sql="insert into think_test (name,email) values ('lee','[email protected]')"; //$result=DB::insert($sql); $array_data=array(); $array_data[0]['name']='tom'; $array_data[0]['email']='[email protected]'; $array_data[1]['name']='jerry'; $array_data[1]['email']='[email protected]'; $result=DB::table('think_test')->insert($array_data); //dump($result);exit; if($result===false){ echo 'insert error';exit; } //列表 /*$sql="select name from think_test where id>1 order by id desc limit 0,20"; //echo $sql;exit; $list=DB::select($sql);*/ /*$list=DB::table('think_test')->select('id','name','email')->where('id', '>', 1)->offset(2)->limit(2)->orderBy('id', 'desc')->get()->toArray(); $list=$this->object_to_array($list);*/ //dump($list);exit; //单行 $info= DB::table('think_test')->where('id','>', '1')->first(); $info=$this->object_to_array($info); //dump($info);exit; //单字段 $email = DB::table('think_test')->where('id','=', '3')->value('email'); //dump($email);exit; //指定字段增加或减少 //$result=DB::table('think_test')->where('id','=', '1')->increment('votes', 5); //指定字段增加,返回的是影响的行数... //$result=DB::table('think_test')->where('id','=', '1')->decrement('votes', 5); //指定字段减少,返回的是影响的行数... //dump($result);exit; //删除 //$result=DB::table('think_test')->where('id','>', '8')->delete(); //返回影响的行数 //dump($result);exit; //清空表 删减表 //$result=DB::table('think_test')->truncate(); //成功清空时返回null //dump($result);exit; return view('index',compact('title','list','info','email')); } }