มาเรียนรู้การสร้างตารางในฐานข้อมูลให้เหมาะกับ cakephp กันดีกว่าคับ

การตั้งชื่อตารางฐานข้อมูล

  • ชื่อตารางต้องเป็นพหูพจน์ เช่น contents
  • Field แรกของตารางต้องเป็น PK autonumber และต้องมีชื่อว่า id

ตัวอย่างตาราง contents ในฐานข้อมูล
CREATE TABLE `contents` (
  `id` int(11) NOT NULL auto_increment,
  `types_id` int(11) NOT NULL,
  `users_id` int(11) NOT NULL,
  `title` varchar(255) collate utf8_unicode_ci NOT NULL,
  `headline` text collate utf8_unicode_ci NOT NULL,
  `detail` text collate utf8_unicode_ci,
  `created` datetime default NULL,
)  ;