2014-03-25 3 views
5

이 오류가 발생하며 이유를 파악할 수 없습니까? where 절에 'id'가 모호합니다.

/home/www/REMOVED/models/lead.php

: 절은

SELECT `leads`.*, 
     `customers`.`id` AS customers_id, 
     `customers`.`name` AS customers_name, 
     `customers`.`company` AS customers_company, 
     `customers`.`email` AS customers_email, 
     `customers`.`phone` AS customers_phone, 
     `customers`.`created_at` AS customers_created_at, 
     `customers`.`updated_at` AS customers_updated_at, 
     `customers`.`ip_address` AS customers_ip_addressFROM (`leads`) 
JOIN `customers` ON `customers`.`id` = `leads`.`customer_id` 
WHERE `id` = '3' 
    AND `leads`.`id` = '1'LIMIT 1 

파일 이름 모호한 곳에서 1052
열 'ID'

오류 번호 행 번호 : 12

T 그 기능은 다음과 같습니다

function get($id) 
{ 
    $this->db->select('leads.*, customers.id AS customers_id, customers.name AS customers_name, customers.company AS customers_company, customers.email AS customers_email, customers.phone AS customers_phone, customers.created_at AS customers_created_at, customers.updated_at AS customers_updated_at, customers.ip_address AS customers_ip_address'); 
    $this->db->where('leads.id', '1'); 
    $this->db->from('leads'); 
    $this->db->join('customers', 'customers.id = leads.customer_id'); 
    $this->db->limit(1); 
    $query = $this->db->get(); 

    if ($query->num_rows() == 1) 
    { 
    $result = $query->result(); 
    return $result[0]; 
    } 
} 

그리고 라인 (12)가 $query = $this->db->get();

무엇이 잘못인가?

답변

11
WHERE id = '3' 

id 필드의 출처를 지정하지 않았습니다. 당신은 의미 했습니까 :

WHERE customer.id = '3' 
+0

내 코드에 지정 했습니까? $ this-> db-> join ('customers', 'customers.id = leads.customer_id'); – Casperlarsen

+0

thats 조인 절 - SQL 샘플에서 WHERE 절을 보자. 바로 거기에 –

+0

그러나 내 코드에서 테이블을 지정합니까? $ this-> db-> where ('leads.id', '1'); – Casperlarsen