2012-06-18 84 views
3

我最近不得不修改下面的SQL這樣:奇怪的SQL錯誤IIS 7

$this->db->select('StaffMembers.Id AS StaffMembers_Id, Contacts.AssociatedStaffMember_Id'); 
$this->db->join("StaffMembers", "Contacts.AssociatedStaffMember_Id=StaffMembers.Id");     
$q1 = $this->db->get_where($this->contacts_table, 'Contacts.AssociatedStaffMember_Id ='.$ContactId); 
$s = $q1->row_array(); 

然而,當我登錄時,它會顯示一箇舊的SQL:

A Database Error Occurred 
Error Number: 

Invalid column name 'Contact_Id'. 

SELECT Contacts.Id, StaffMembers.Id AS StaffMember_Id 
FROM StaffMembers JOIN Contacts ON Contacts.Id=StaffMembers.Contact_Id 
WHERE Contacts.Id =161 

我已經重新啓動MSSQL服務器,刷新memcached和iis7,但它仍然顯示舊的查詢。不知道,爲什麼地球上這麼做,有什麼想法?

發現的問題,似乎是在控制器類中的一些重複的SQL(當有不應該的!)

修正了 - 問題就解決了。乾杯。

+0

您是否在CodeIgniter中使用某種查詢緩存機制? [CI數據庫緩存(http://codeigniter.com/user_guide/database/caching.html) – Quantastical

+0

都能跟得上不是,我知道了,有沒有檢查的快捷方式? – thejoker

+0

查找範圍爲線設置'$分貝[ '缺省'] [ 'cache_on']'的值配置文件(application /配置/ database.php中)。如果您不僅僅使用默認值,請務必檢查您的應用程序的配置文件。 – Quantastical

回答

0

這是否解決任何問題?

$this->db->select('StaffMembers.Id AS StaffMembers_Id, Contacts.AssociatedStaffMember_Id'); 
$this->db->join("StaffMembers", "Contacts.AssociatedStaffMember_Id=StaffMembers.Id"); 
$this->db->where('Contacts.AssociatedStaffMember_Id', $ContactId); 
$q1 = $this->db->get($this->contacts_table); 
$s = $q1->row_array(); 

你以前的代碼使用get_where和我不是100%肯定是否可以混合使用。

你有沒有在運行此代碼之前操縱$this->db類的基礎類?

gav

+0

解決了這個問題,在控制器中似乎出現了一些導致問題的SQL代碼。必須刪除它。 – thejoker