yakczh
V2EX  ›  问与答

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

  •  
  •   yakczh · Jul 20, 2015 · 1802 views
    This topic created in 3984 days ago, the information mentioned may be changed or developed.

    $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  
       Jul 20, 2015
    这是laravel?。
    好处就是不用管表前缀等等,而且大都操作单表增删改查不需要sql
    123123
        2
    123123  
       Jul 20, 2015
    用 bind 还可以省去自己写转换代码防注入
    yakczh
        3
    yakczh  
    OP
       Jul 20, 2015
    @123123 bind以后,怎么debug查看 sql 日志?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3376 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 48ms · UTC 11:29 · PVG 19:29 · LAX 04:29 · JFK 07:29
    ♥ Do have faith in what you're doing.