作者HuangJC (吹笛牧童)
看板PHP
標題[CakePHP] 請問 recursive
時間Mon May 18 20:11:48 2009
同事的程式中有這一句
$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
→ gpmm :看到「整段翻譯對我有些困難,麻煩講解了」 05/18 20:29
→ gpmm :真的不知道該說什麼… 05/18 20:29
→ HuangJC :應該是說,翻出來的東西無法想像吧.. 05/18 20:42
→ HuangJC :就以我實測來說,有沒有 recursive(設成-1)並沒差別 05/18 20:43
→ HuangJC :所以只好猜那段 code 目前不重要 05/18 20:43
→ gpmm :google 關鍵字下 CakePHP findAll recursive 05/18 20:54
→ gpmm :小弟沒在用 Cake 所以不知其正確性,但也同樣不確定 05/18 20:55
→ gpmm :您是否有 google 過這些您的疑惑… 05/18 20:55
→ gpmm :若有,小弟在此跟您說聲抱歉 05/18 20:55
→ HuangJC :謝謝,應該就是那段的描述,它可以減短花在 left join 05/18 21:07
→ HuangJC :的路徑;而 find 本身就會使用 left join 我還沒看通 05/18 21:07
※ 編輯: HuangJC 來自: 61.219.65.16 (05/18 21:13)