/** * Generate Student ID. year(2) + month(2) + day(2) + serial(4): 1204050027 */ protected function generateStudentId() { $time = date('ymd'); $cond['id'] = array('LIKE', "{$time}%"); $number = DBModel::countByCond('cernet_user', $cond); $number++; $number = '' . $number; while (strlen($number) < 4) { $number = '0' . $number; } return $time . $number; }