0
App::import('model','User');
$user_model = new User();
$xxx = $user_model->find("all", array("fields"=>array("User.yyy")));
$zzz = $user_model->find("count", array("fields" => "User.yyy"));
$arr = array();
for($i=0; $i<=$zzz; $i++){
$rs = $xxx["i"]["User"]["yyy"];
array_push($arr , $rs);
}
print_r($arr);
위의 cakephp 코드를 사용하여 mysql 결과 집합으로 $ xxx를 얻는다.cakephp mysql 결과를 간단한 배열로 변환하는 방법
mysql 테이블의 "yyy"필드에 해당하는 모든 값을 arrray에 저장해야합니다.
나는 결과 집합을 인쇄하려고이 같은 결과를 얻었다 : - 나는 위의 코드를 실행 한 후print_r($zzz)= 1646 // prints the total number of results
print_r($xxx[0]["User"]["yyy"]) = abcde //the first element of the result set
는, 그냥 빈 배열을 인쇄합니다.
누군가 나를 도와 줄 수 있습니까 ??