Laravel 5.2 - pluck() method returns array

前端 未结 5 739
悲&欢浪女
悲&欢浪女 2020-12-04 21:13

I\'m trying to upgrade my project L5.1 -> L5.2. In upgrade guide there\'s one thing which isn\'t clear for me:

The lists method on the Co

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 21:49

    In the original example, why not use the select() method in your database query?

    $name = DB::table('users')->where('name', 'John')->select("id");
    

    This will be faster than using a PHP framework, for it'll utilize the SQL query to do the row selection for you. For ordinary collections, I don't believe this applies, but since you're using a database...

    Larvel 5.3: Specifying a Select Clause

提交回复
热议问题