V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
yakczh
V2EX  ›  问与答

builder 模式写的 sql 相比直接写 sql 有什么好处?

  •  
  •   yakczh · 2015-07-20 16:41:44 +08:00 · 1428 次点击
    这是一个创建于 3204 天前的主题,其中的信息可能已经有所发展或是发生改变。

    $users = DB::table('users')
    ->join('contacts', 'users.id', '=', 'contacts.user_id')
    ->join('orders', 'users.id', '=', 'orders.user_id')
    ->select('users.*', 'contacts.phone', 'orders.price')
    ->get();

    xujif
        1
    xujif  
       2015-07-20 17:09:29 +08:00
    这是laravel?。
    好处就是不用管表前缀等等,而且大都操作单表增删改查不需要sql
    123123
        2
    123123  
       2015-07-20 17:57:03 +08:00
    用 bind 还可以省去自己写转换代码防注入
    yakczh
        3
    yakczh  
    OP
       2015-07-20 19:22:25 +08:00
    @123123 bind以后,怎么debug查看 sql 日志?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   878 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:45 · PVG 05:45 · LAX 14:45 · JFK 17:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.