Cakephp afterFind不使用递归级别2
后发现问题 当前代码: 当我尝试查找房间数据时:Cakephp afterFind不使用递归级别2,cakephp,cakephp-2.0,cakephp-model,Cakephp,Cakephp 2.0,Cakephp Model,后发现问题 当前代码: 当我尝试查找房间数据时: 这可能是绑定飞越时$reset的问题 请将$reset设置为false $this->Model->bindModelarray…,false 不要使用递归的任何东西。在AppModel中将其设置为-1,然后在需要其他关联数据时使用Containable行为。 <?php public function afterFind($results, $primary = false) { foreach
这可能是绑定飞越时$reset的问题 请将$reset设置为false
$this->Model->bindModelarray…,false 不要使用递归的任何东西。在AppModel中将其设置为-1,然后在需要其他关联数据时使用Containable行为。
<?php
public function afterFind($results, $primary = false)
{
foreach ($results as $key => $val)
{
if (isset($val['User']['country_code']) && isset($val['User']['mobile']))
{
$results[$key]['User']['mobile'] = trim($val['User']['country_code']).trim($val['User']['mobile']);
}
}
return $results;
}
?>
<?php
$this->Place->bindModel(array('belongsTo' => array('User')));
$this->Room->bindModel(array('belongsTo' => array('Place')));
?>
<?php
$data = $this->Room->find('first');
array(
[Room] => array()
[Place] => array(
[User] => array(
[mobile] => /* here after find not working it should content country code + mobile */
)
)
)
?>