【问题标题】:Bizarre SQL bug IIS 7奇怪的 SQL 错误 IIS 7
【发布时间】:2012-06-20 16:52:53
【问题描述】:

我最近不得不将以下 SQL 修改为:

$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(不应该有!)

已修复 - 问题已解决。干杯。

【问题讨论】:

  • 你在 CodeIgniter 中使用了某种查询缓存机制吗? CI Database Caching
  • 不,我不知道,有没有快速检查的方法?
  • 在配置文件 (application/config/database.php) 中查找为$db['default']['cache_on'] 设置值的行。如果您不只是使用默认设置,请务必检查应用程序的配置文件。
  • 设置为false:$db['default']['dbprefix'] = ""; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = TRUE; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = ""; $db['default']['char_set'] = "utf8"; $db['default']['dbcollat​​'] = "utf8_general_ci";
  • 您可以在开始选择语句之前尝试添加$this->db->flush_cache();,以确认它是/不是缓存。

标签: php sql codeigniter iis-7


【解决方案1】:

这是否能以任何方式解决问题?

$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

【讨论】:

  • 解决了这个问题,控制器中似乎有一些 SQL 代码导致了问题。不得不删除它。
猜你喜欢
  • 2011-06-03
  • 1970-01-01
  • 1970-01-01
  • 2011-01-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-08
相关资源
最近更新 更多