Skip to content

Instantly share code, notes, and snippets.

@taichunmin
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taichunmin/62c1e527e472d997ef4d to your computer and use it in GitHub Desktop.
Save taichunmin/62c1e527e472d997ef4d to your computer and use it in GitHub Desktop.

有關 Laravel 的 Query Build 的資料回傳型態疑問

一直覺的 laravel 的文件寫的不夠詳細

之前在看 EloquentQuery Builder

以為他們的回傳是一樣的

所以再寫程式碼的時候

撞了不少的墻

但是又困擾於不知道該如何找到資料


今天終於下定決心去看 Source Code

終於發現

原來 Query Builder 回傳的根本就是 PDO::fetchAll()

這樣就好辦

於是才解決這個困惑我很久的疑問~


另外 又發現

DBsetFetchMode() 的函式可以設定 PDO::FETCH_STYLE

然後也可在 database.php 中直接指定


學到好招啦~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment