Hello,
-- I got solution. Please read http://goo.gl/qxL8QR
Regards,
On Wednesday, 11 December 2013 16:53:53 UTC+5:30, Sanjeev Divekar wrote:
On Wednesday, 11 December 2013 16:53:53 UTC+5:30, Sanjeev Divekar wrote:
Hello,I am facing strange problem first time. I am trying to insert simple records in database with Custom Auto Increment Values e.g 00001, 00002, 00003. but unable to get Incremented value. Each record get updated with same max number.Controller Codepublic function dobulk() {for($i=0;$i<5;$i++) {$data = array();$this->Tmp->create();$data['Tmp']['invoice_no'] = $this->Tmp->get_no();$data['Tmp']['invoice_date'] = '2013-12-11';$this->Tmp->save($data);}}Model Codepublic function get_no() {$strSql = "SELECTLPAD(IFNULL(RIGHT(MAX(invoice_no),5),0) + 1,5,'0') AS max_id FROM tmps;";$result = $this->query($strSql);$invoice_no = $result[0][0]['max_id'];return $invoice_no;}Database TableCREATE TABLE `tmps` (
`id` int(10) unsigned NOTNULL AUTO_INCREMENT,
`invoice_no` varchar(20)DEFAULT NULL,
`invoice_date` date DEFAULTNULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET= latin1 Thanks in advance.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment