我不知道如何在变量和数组中传递,如何在foreach循环中传递$ query变量并使用return
public function test($id){
$sql = 'SELECT * FROM '.SELF::TABLE_MEMBERS_CONTAINER. ' c
LEFT JOIN '.SELF::TABLE_MEMBER.' m ON
c.members_id = m.id
LEFT JOIN '.SELF::TABLE_CONTAINER.' ct ON
c.container_id = ct.id
WHERE c.members_id = '. $id . ' ORDER BY c.created_at desc';
$row = $this->query_rows( $sql );
foreach ($row as $r ) {
$i++;
$sql = 'SELECT * FROM `'.SELF::TABLE_STATUS_CONTAINER.'` WHERE container_id = ' .$r['container_id'];
$query = $this->query_rows( $sql );
var_dump($query);
}
return array(
'data'=>$row,
);
}
我试着
return array(
'data'=>$row,
'query'=>$query,
);
当我在内部循环var_dump时它返回
bool(false)
array(2) {
[0]=>
array(7) {
["id"]=>
string(1) "1"
["container_id"]=>
string(1) "3"
["title"]=>
string(51) "teat"
}
[1]=>
array(7) {
["id"]=>
string(1) "2"
["container_id"]=>
string(1) "3"
["title"]=>
string(72) "te"at
}
}
bool(false)
但是当我转移到外部循环时,它只返回
布尔(假)