[CakePHP] 請問 recursive

看板PHP作者 (吹笛牧童)時間15年前 (2009/05/18 20:11), 編輯推噓0(0012)
留言12則, 2人參與, 最新討論串1/3 (看更多)
同事的程式中有這一句 $this->User->findByEmail($email, null, null, -1) 經翻查 findBy 的章節,help 是這樣寫的 findBy<fieldName>(string $value) 難怪我上次學習 Cake 時,大家看不懂這是什麼 但如果去 trace source code,會發現它真的能動! (X啦,超過文件的規格可以視為 side effect 呀!!) 好吧,我就繼續 trace,發現 recursive 其實在別的章節找得到文件 比如在 findAll findAll(string $conditions, array $fields, string $order, int $limit, int $page, int $recursive) findAll has been deprecated, use find('all') instead. 這句有趣吧,help 說 findAll 已經不建議使用了 但是 CakePHP 內部還是用它 implement 的,用得很爽 換言之就是 'UnDocument' (應該說文件不推薦才對,因為文件還是把它列出了) 那什麼是 recursive 呢? Setting the $recursive parameter to an integer forces findAll() to fetch data according to the behavior described in the Model Attributes $recursive section outlined earlier. Do not forget to manually add the required foreign key columns to the $fields array as described there. 以上,整段翻譯對我有些困難 ~^_^~ 麻煩講解了 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.219.65.16

05/18 20:29, , 1F
看到「整段翻譯對我有些困難,麻煩講解了」
05/18 20:29, 1F

05/18 20:29, , 2F
真的不知道該說什麼…
05/18 20:29, 2F

05/18 20:42, , 3F
應該是說,翻出來的東西無法想像吧..
05/18 20:42, 3F

05/18 20:43, , 4F
就以我實測來說,有沒有 recursive(設成-1)並沒差別
05/18 20:43, 4F

05/18 20:43, , 5F
所以只好猜那段 code 目前不重要
05/18 20:43, 5F

05/18 20:54, , 6F
google 關鍵字下 CakePHP findAll recursive
05/18 20:54, 6F

05/18 20:54, , 7F
可以找到這筆 http://0rz.tw/MntrB
05/18 20:54, 7F

05/18 20:55, , 8F
小弟沒在用 Cake 所以不知其正確性,但也同樣不確定
05/18 20:55, 8F

05/18 20:55, , 9F
您是否有 google 過這些您的疑惑…
05/18 20:55, 9F

05/18 20:55, , 10F
若有,小弟在此跟您說聲抱歉
05/18 20:55, 10F

05/18 21:07, , 11F
謝謝,應該就是那段的描述,它可以減短花在 left join
05/18 21:07, 11F

05/18 21:07, , 12F
的路徑;而 find 本身就會使用 left join 我還沒看通
05/18 21:07, 12F
※ 編輯: HuangJC 來自: 61.219.65.16 (05/18 21:13)
文章代碼(AID): #1A4L26BU (PHP)
文章代碼(AID): #1A4L26BU (PHP)