Код: Выделить всё
+------------+
| auto_no |
+------------+
| 2020-00821 |
| 2020-00822 |
| 2020-00823 |
| 2020-00824 |
| 2020-00825 |
+------------+
Код: Выделить всё
public function generate_auto_no($count = 1, $start = 00000, $digits = 5)
{
$query = $this->db->get('letter_letter');
$this->db->select("MAX(CAST(SUBSTRING_INDEX(auto_no, '-', -1) AS UNSIGNED)) AS auto_no", FALSE);
$count = ($query->num_rows() > 0) ? $query->row()->auto_no + 1 : 0;
$result = array();
for ($n = $start; $n
Подробнее здесь: [url]https://stackoverflow.com/questions/59909501/select-max-formatted-string-from-a-column-using-codeigniters-query-builder[/url]
Мобильная версия