作者:
anawak (...)
2014-07-18 12:31:52平常操作資料庫獲得的資料都是二維陣列:$rows[列數][欄位名]
例如,假設要獲取文章的資料,資料表叫 Post。常撈出來的結果像這樣
[0] => Array
(
[id] => 1
[title] => First article
[content] => aaa
[created] => 2008-05-18 00:00:00
)
[1] => Array
(
[id] => 2
[title] => Second article
[content] => bbb
[created] => 2008-05-18 00:00:00
)
但是 cakephp 會在中間多一層,把資料表名稱放進去:
[0] => Array
(
[Post] => Array
(
[id] => 1
[title] => First article
[content] => aaa
[created] => 2008-05-18 00:00:00
)
)
[1] => Array
(
[Post] => Array
(
[id] => 2
[title] => Second article
[content] => bbb
[created] => 2008-05-18 00:00:00
)
)
我知道這個另有用處。但是如果不想要中間多那一層,該如何處理?
$postData = $this->Post->find('all',array(??), array(??));