내 사용자가 내 응용 프로그램에 로그인하여 그들이 속한 '커뮤니티'목록을 검색 할 때 SQL 쿼리를 실행하고 있습니다.이 함수는 5의 배열이어야하는 것 중에서 첫 번째 값만 반환하는 이유는 무엇입니까?
내 주소 표시 줄에 직접 로그인 링크를 붙여 넣어 어떤 값이 반환되는지 테스트하려고합니다.
그것은 5 개 항목의 배열을 반환해야하지만, 단지 내가 phpMyAdmin을에서 SQL 쿼리를 테스트 한 올바른 결과를 반환 1.
반환합니다.
내가 뭘 잘못하고 있니?
이이 현재 브라우저에서 {"name":"EnclliffeT"}
을 반환 MySQLDao.php
public function getCommunities($email){
$returnValue = array();
$sql = "SELECT communities.name \n"
. "FROM users \n"
. "join community_players \n"
. "on community_players.player_id=users.id \n"
. "join communities \n"
. "on communities.id=community_players.community_id \n"
. "WHERE users.user_email = '".$email."'";
$result = $this->conn->query($sql);
if($result != null && (mysqli_num_rows($result) >= 1)){
$row = $result -> fetch_array(MYSQLI_ASSOC);
if(!empty($row)){
$returnValue = $row;
}
}
return $returnValue;
}
에 다음 함수를 실행 userLogin.php
$communities = array();
$communities = $dao->getCommunities($email);
echo json_encode($communities);
에서입니다. 그러나 다른 4 개의 항목이 있어야합니다.
이 – RiggsFolly
'$ 행 = $ 결과를 설정 -> fetch_array (MYSQLI_ASSOC)'이에서 $의 대체되어 while 루프 – RiggsFolly