【发布时间】:2015-06-24 06:53:12
【问题描述】:
在我导入从 Excell 到 DB 之后,我尝试从 DB 中选择我的数据,如下代码
问题如果我复制 In_no 值 (isp14065556) 并传递到文本编辑器并传递回表中的 in_no,那么我的 select by where 也会起作用。为什么?
我的 In_no 类型的表是 varchar(30),我使用 In_no 作为 Where 子句。
问题如果我通过键入插入 in_no 字符串值,我可以通过 where 选择,如果 In_no 字符串值,我无法通过 where 选择从 Excel 中导入(in_no 内容存储在 Excel 中并导入到 Db)。
我不明白为什么,因为 in_no 类型是 varchar(30) 并且我在使用 Where 子句选择数据方面有更多经验来自 DB 很多次。但是这个我真的不明白为什么我从excel导入数据时无法选择数据。
public function printds(){
$segment = $this->uri->segment(3);
$this->db->select('*');
$this->db->from('dbfinan_dupl_invoice');
$this->db->where('in_no',$segment);//tested arary('in_no'=>$segment)
$query = $this->db->get();
return $query->result();
}
在控制器中
public function printd(){
$segment = $this->uri->segment(3);
$this->data['invoice_val'] = $this->invoice_m->select_ad_val($segment);
$this->data['print_item'] = $this->invoice_m->printds($segment);
$this->load->view('frontend/print/print_dup',$this->data);
}
非常感谢朋友的好意
【问题讨论】:
-
您是否遇到任何错误?
$segment的值是多少? -
$segment = $this->uri->segment(3);我将它从控制器传递给模型
-
@Uchiha 我不明白当我通过键入它的值在 DB 中编辑 In_no 时它会起作用。但它无法选择我是否使用 where 子句和从 Excel 导入的 in_no 值。为什么因为它也是字符串
-
尝试使用
echo $this->db->last_query();并在sql中发布该查询并检查它是否在那里工作 -
有效吗?你在sql里面试过了吗
标签: php mysql sql-server excel codeigniter