我试图获取没有型号名称的json数据,所以在这里我尝试了如下代码的提取
$transaction = $this->Transaction->find('all', array('conditions'=>array('Transaction.user_id'=>$id)));
$transaction = Set::extract('/Transaction/.', $transaction);
问题是我现在没有在json输出中获得关联数据。这是json的样子
[{"id":"130","transaction_type":"1","user_id":"44","entry_by":"pitocms","added_id":"25","perticuler":"test","Volume":null,"per_unit":null,"credit_money":"1500","debit_money":"0","balance":"-1500","created":"2015-12-27 21:21:11","modified":"2015-12-27 21:21:11"}]
实际上有2个模型交易和用户。
答案 0 :(得分:1)
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# redirect while under construction
RewriteCond %{REMOTE_ADDR} !^my\.ip\.addr\.ess$
RewriteCond %{REQUEST_URI} !construction\.html
RewriteRule ^(.*)$ /construction.html [R=302,L]
# remove .html extensions from the URL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
# convert html to php without changing the extension
AddType application/x-httpd-php .htm .html
ErrorDocument 404 /errors/404.html
完全相同,它在从源数组中提取所选数据后创建一个新数组。因此,为了获取用户信息,您还必须提取它:
Set::extract()
正如@ndm在评论中所述,课程$data = $this->Transaction->find('all',array('conditions'=>array('Transaction.user_id'=>$id)));
$transactions = Set::extract('/Transaction/.', $data);
$users = Set::extract('/User/.', $data);
长期以来一直被弃用,而不是课程Set
。您可以通过以下方式实现相同目标:
Hash