Это моя таблица БД ИЗОБРАЖЕНИЕ
</p>
<ol>
<li><p>I Have This code but, the result is this: </p>
<p>array:2 [▼
3 => array:1 [▼
1 => []
]
4 => array:1 [▼
5 => array:1 [▼
6 => array:1 [▼
7 => []
]
]
]
]</p></li>
<li><p>But i need organize the code like this:</p>
<p>array:[</p>
<p>0 => 3,
1 => 1,
2 => 4,
3 => 5,
4 => 6,
5 => 7</p>
<p>]</p></li>
</ol>
<p>
// actually the parameter id is the session user
public function misSubordinados($id){
$conn = $this->getEntityManager()->getConnection();
$sql = 'SELECT s.id_usuario FROM `sy_supervisores_asesor` AS s
WHERE s.id_supervisor IN (' . implode(',', [$id]) . ')';
$stmt = $conn->prepare($sql);
$stmt->execute();
$total = array();
$result = $stmt->fetchAll();
if(count($result) > 0) {
foreach ($result as $key => $value) {
$total[$value['id_usuario']] = $this->misSubordinados($value['id_usuario']);
}
}
return $total;
}