作者anawak (...)
看板PHP
标题[请益] cakephp的资料集
时间Fri Jul 18 12:31:52 2014
平常操作资料库获得的资料都是二维阵列:$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(??));
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 111.248.113.44
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/PHP/M.1405657915.A.FCB.html