NeedZoom Posted May 18, 2016 Share Posted May 18, 2016 Hi, I have a field in table customer DB.but i want his value like "generateReference". How can i do it with pro technique thanks Link to comment Share on other sites More sharing options...
NeedZoom Posted May 18, 2016 Author Share Posted May 18, 2016 i have add ALTER TABLE `ps_customer` ADD `code` VARCHAR(9) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ; and in customer.php: in public static $definition: 'code' => array('type' => self::TYPE_STRING), and public static function generateCode() { $last_id = Db::getInstance()->getValue(' SELECT MAX(code) FROM '._DB_PREFIX_.'customer'); return str_pad((int)$last_id + 1, 8, 'CW0000000', STR_PAD_LEFT); } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now