2011-09-10 2 views
0

내가이 때문에을 찾는 중 PHP 준비된 성명 필드 데이터

$stmt->execute(); 
$fieldcnt = $stmt->field_count; 

을 한 후 나는 내가 때까지 SELECT에 얼마나 많은 필드 모르는 문 SELECT; 제조 된 Mysqli 확장과 PHP를 사용하고, 나는, 나는 contruct 방법을 모르는 내가 돌아왔다 얼마나 많은 필드를 알 수 없기 때문에, 즉

$stmt->bind_result(list of parms); 

을 수행하는 데 문제가 "PARMS의 목록을."

그래서, 반환 된 필드에 액세스하는 방법에 대한 조언이 필요합니다.

답변

1

bind_result를 사용하지 말고 fetch_assoc()을 사용하십시오.

은 각 행에 대해 관련 배열을 반환합니다 : 당신은이 작업을 수행하는 call_user_func_array()을 활용할 수

while ($row = $stmt->fech_assoc()) { 
    print_r($row); 
} 
0

- 당신이 절대적으로 bind_result()를 사용해야하는 경우.

// create an array the size of the number of parameters 
$params = array_fill(0, $fieldcnt, null); 

// call bind_result, resulting in every column of the result to be 
// bound to a value in $params 
call_user_func_array(array($stmt, 'bind_result'), $params); 

// take a look at all the params 
print_r($params); 
관련 문제