从Codeigniter中的excel导入时,我无法使用where子句选择数据(I can't select data using where clause when imported fr

编程入门 行业动态 更新时间:2024-10-27 16:36:36
从Codeigniter中的excel导入时,我无法使用where子句选择数据(I can't select data using where clause when imported from excel in Codeigniter)

我从Excell 导入 DB后尝试从DB中选择我的数据,如下面的代码所示

问题如果我复制In_no值(isp14065556)并传入文本编辑器并传回表中的in_no,我的选择也将起作用。 为什么?

我的In_no类型表是varchar(30) ,我使用In_no作为Where子句

如果我通过键入插入in_no字符串值,我可以选择问题我无法选择从Excel导入的In_no字符串值的位置( 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); }

非常感谢你的朋友

I have try to select my data from DB after I imported from Excell into DB as below code

Problem If I copy In_no value (isp14065556) and pass into text editor and pass back into in_no in the table my select by where will work as well. Why?

My table of In_no type is varchar(30) and I used In_no for Where clause.

Issue I can selected by where if I insert in_no string values by typing and I can't select by where if In_no string value which imported from Excel ( in_no content which store in Excel and was imported into Db).

I don't understand why because in_no type is varchar(30) and I have more experience with using Where clause to select data from DB a lot of times. But this one I'm really don't understand why I can't select data when its was imported from 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(); }

And in controller

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); }

Thanks too much friend for your kind

最满意答案

请使用此代码

$segment = $this->uri->segment(3); $data['invoice_val'] = $this->invoice_m->select_ad_val($segment); $data['print_item'] = $this->invoice_m->printds($segment); $this->load->view('frontend/print/print_dup',$this->data);

@Uchiha @Abdulla Now I found the solution Feeling happy to much

'in_no' => strtolower(trim(preg_replace("/(\D+\d{4})0*([1-9]+\d*)/i", "$1$2\n", strtolower($data['IN_number'])))),

I didn't clean in_no But after I used strtolower and trim it work as perfect Thanks friend for some idear

更多推荐

本文发布于:2023-08-05 06:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1428761.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:子句   数据   excel   Codeigniter   imported

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!