When creating an article, you need to create its id from a date and look like this: 20180926203005 (year, month, day, hour, minute, second). Is it possible?

if ($db->exec("CREATE TABLE 'article' ('id' INTEGER PRIMARY KEY AUTOINCREMENT DATE NOT NULL UNIQUE, 'title' VARCHAR(20), 'category' INT(3), 'date' VARCHAR(50))")) $id = date('YmdHis'); if($db->exec("INSERT INTO user VALUES ('$id','Title Article',Category1,'date('YmdHis')')")) 

This design does not work.

  • It is a bad idea. Get a separate date field, and leave the id alone. - user207618
  • Why bad? - Linne
  • Why mix what is not intended for this? And if in one second add two records? - user207618
  • Well, in general, yes. But, however, when removing id = 2, the rest are not shifted, and in the future is assigned in order, and id = 2 will no longer be in the database. - Linne

0