私は3つのテーブルを持っていplayers
ますfield id
、、。テーブル内のすべてのプレーヤーを表示するhaveメソッド:first_name
last_name
PlayersController
index
public function index() {
$output = $this->Player->find('all');
$this->set(array(
'output' => $output,
'_serialize' => array('output')
));
$this->render('generic_response');
}
generic_responseは、次のようなXMLビューです。
<?php
$xml = Xml::fromArray(array('response' => $output));
echo $xml->asXML();
結果のXMLは次のとおりです。
<response>
<output>
<Player>
<id>2</id>
<first_name>Ciro</first_name>
<second_name>Spee</second_name>
</Player>
</output>
<output>
<Player>
<id>3</id>
<first_name>Ugo</first_name>
<second_name>Ridi</second_name>
</Player>
</output>
</response>
しかし、私は次のようなものが欲しいです:
<response>
<players>
<Player>
<id>2</id>
<first_name>Ciro</first_name>
<second_name>Spee</second_name>
</Player>
<Player>
<id>3</id>
<first_name>Ugo</first_name>
<second_name>Ridi</second_name>
</Player>
</players>
</response>
これどうやってするの?