Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cakephp afterFind不使用递归级别2_Cakephp_Cakephp 2.0_Cakephp Model - Fatal编程技术网

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 */
        )
    )
)
?>