2009-07-20 8 views
0

내가 배열배열 문제, where 절

먼저 내가 다음

$this->db->select('zip'); 
    $this->db->from('custom_city'); 
    $this->db->join('city_to_zip', 'custom_city.id = city_to_zip.city_id', 'left'); 
    $this->db->where('city_to_zip.city_id', $_POST['city']); 
    $zip = $this->db->get(); 
    $data['zips'] = $zip; 

    $zip_array = $zip->result_array(); 

을 필요로하는 모든 지퍼를 얻을 수있는 쿼리를 실행으로 쿼리 결과를 사용하려고 몇 가지 문제가 있어요에서 쿼리 출력은 사용하려고 할 때 출력됩니다.

"배열"이 8 번이고 쿼리에 적합한 개수이기 때문에 뭔가를하고 있다는 것을 알고 있습니다. 단어 배열 대신에 우편 번호를 가져 오는 법을 알아야합니다.

내 쿼리에
AND `zip_code` IN (Array, Array, Array, Array, Array, Array, Array, Array) [/quote] 

내가 사용하고 ...

$this->db->where_in('zip_code', $zip_array); 

감사합니다,

Jbeasley

+0

너무 감사합니다. 이것은 나를 위해 일했습니다. \t \t $ zip_array = array(); \t \t foreach ($ zip-> result() $ 행) : { \t \t $ zip_array [] = $ row-> zip; } \t \t endforeach; – jBeas

답변

3

result_array() 그렇게 (각 행에 대해 연관 배열을 반환하기 때문에 이것은 당신 ' 어레이의 배열을 다시 얻음). $zip_array에 우편 번호를 얻으려면,이 라인을 교체 :

$zip_array = $zip->result_array(); 

$zip_array = array(); 
$result = $zip->result_array(); 
foreach ($result as $row) { 
    $zip_array[] = $row['zip']; 
} 

Documentation on result_array()