【发布时间】:2013-02-17 09:58:12
【问题描述】:
我有一段用 Codeigniter 框架编写的 PHP 代码,它什么都不返回(一个空集)。 看看它,告诉我它有什么问题。
function sbsn($serial){
$this->db->select('asset_types.name as type_name,asset_brands.name as brand_name');
$this->db->from('asset_types,asset_brands,assets');
$this->db->where('assets.type_code','asset_types.code');
$this->db->where('assets.brand_code','asset_brands.code');
$this->db->where('serial_no',$serial);
$result = $this->db->get();
return $result;
}
【问题讨论】:
-
您是否在数据库控制台中运行了等效查询?在 CodeIgniter 中,您能否打开查询日志记录以确保将语句按您的意图发送到数据库服务器?
-
您的 Where 语句是否正确?您检查 assets.type_code 是否为“asset_types.code”字符串
标签: php sql codeigniter