Cakephp version 2.5.1, import file (csv format), database (mssql)
i have imported the csv file and saved into database, after save i want to display each of the 'current' import data using html table in cakephp. My problem is i don't have idea to code for find current batch upload where each batch start point from L01-0-00-00-000 until end L01-0-00-00-999.The L01 on each string will change to L02, L03 and so on.
i try to use this function in mycontroller, it will only show all the table with Line=01
My controller: function index () { $this->set('uploads', $this->Upload->getColumnTypes('all', array('conditions' => array('RAS_Off_Upload.RAS_Code' => ' L01-0-00-00-000' && ' L01-0-00-00-999' )))); }
function index () { $this->set('uploads', $this->Upload->getColumnTypes('all', array('conditions' => array('RAS_Off_Upload.RAS_Code' => ' L01-0-00-00-000' && ' L01-0-00-00-999' )))); }
Thank you for any of the suggestion.
Output table in database: RAS_Off_Upload table
No RAS_Code Value Remark SF Create_by CLN Lot Prod Time Date
1 L01-0-00-00-000 0 test H D123 CLN12345 SLTC123M LN2CPW 7:10 25JUN
2 L01-1-01-01-111 68 test L D123 7:15 25JUN
3 L01-0-01-01-222 40 test L D123 7:18 25JUN
4 L01-0-01-01-333 82 test L D123 7:20 25JUN
5 L01-0-00-00-444 59 test L D123 7:21 25JUN
6 L01-0-00-00-555 59 test L D123 7:23 25JUN
7 L01-0-00-00-666 59 test L D123 7:34 25JUN
8 L01-0-00-00-777 59 test L D123 7:37 25JUN
9 L01-0-00-00-888 59 test L D123 7:40 25JUN
10 L01-0-00-00-999 0 test E D123 7:41 25JUN
I am considering RasOffUpload is your model correspond to RAS_Off_Upload
table.
Try the following:
function index () {
$this->set('uploads', $this->RasOffUpload->find('all',
array('conditions' => array('RasOffUpload.RAS_Code REGEXP' => '^L01-0-00-00-[0-9]*$'))));
}
Use find
method instead of getColumnTypes
. You can also try to use ^L01-0-00-00-[[:digit:]][[:digit:]][[:digit:]]$
.
If in the middle digit is also varies from 0 to 9, then you can use like: ^L01-[[:digit:]]-00-00-[[:digit:]][[:digit:]][[:digit:]]$
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.