控制器,rawSQL,Model

controller.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use DB; class MyController extends Controller
{
public function hello()
{ $articles = DB::select('select * from posts'); return View('myview',['d1'=>$articles]);
}
}

这里控制器给blade页面传递了一个数组,这个数组是直接通过数据库查询来的。

*.blade.php

@extends('layouts.app')

@section('content')
<div class="container">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="panel panel-default">
<div class="panel-heading">{{ count($d1) }}</div> <div class="panel-body">
this is my view!
</div> @for($i = 0; $i < count($d1); $i++)
<p>{{ $d1[$i]->content }}</p>
@endfor </div>
</div>
</div>
</div>
@endsection

最新文章

  1. ump_player在线直播播放器
  2. Upgrade NE script with GUI but cannot support multithread, need to add soon
  3. PC端重置
  4. 【BZOJ3439】Kpm的MC密码 trie树+主席树
  5. LTE Module User Documentation(翻译12)——X2切换(X2-based handover)
  6. 9月15日,YTFCloud,创业圈的技术新宠
  7. 使用Fabric进行crash收集统计
  8. JGibbLDA、GibbsLDA++问题解决
  9. 实现app上对csdn的文章查看,以及文章中图片的保存 (制作csdn app 完结篇)
  10. ASP.NET-FineUI开发实践-12
  11. Java--static interface
  12. liunx清理磁盘du -h --max-depth=1 /data/*
  13. centos6+cdh5.4.0 离线搭建cdh搭建
  14. 浅谈Linux基本命令
  15. Bugku-CTF之成绩单(快来查查成绩吧)
  16. union、union all 、distinct的区别和用途
  17. Java基础之IO流学习总结
  18. Android Studio 3依赖配置
  19. Sumo生成数据
  20. Python Singleton模式

热门文章

  1. html 转义
  2. 360路由器+花生壳实现外网访问SVN服务器
  3. JMeter使用代理录制脚本
  4. jquery 编写插件入门
  5. react中常用的一些方法
  6. MyBatis中的条件判断单引号双引号的使用
  7. 如何在Visio 2007中画接口和实现类的关系图
  8. 在Winfrom下实现类似百度、Google搜索自能提示功能
  9. 关于多字节字符入库失败处理(所谓的Emji),该处理是舍弃特殊字符
  10. boneCP的连接管理