Primary key by UUID()

How to Use Primary Key UUID() for Mariadb?
Tried it and had a problem adding data. But if the data already exists, it can be viewed.

CREATE TABLE `eee` (
	`eee` VARCHAR(50) NOT NULL DEFAULT uuid() COLLATE 'utf8mb4_general_ci',
	`fff` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci',
	PRIMARY KEY (`eee`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=MyISAM
;

ERROR: Warning: Undefined array key “eee” in C:\wamp64\www\sss\models\EeeAdd.php on line 839

In add page not use column ‘eee’.

Since it has nothing to do with PHPMaker itself, you may Google “mysql create table uuid primary key”.

totza2010 wrote:

> > eee > VARCHAR(50) NOT NULL DEFAULT uuid() COLLATE 'utf8mb4_general_ci',

In add page not use column ‘eee’.

That is because you have DEFAULT uuid(), so you don’t need to fill it in Add page.

If adding data without ‘eee’ value, database will populate uuid() , but when adding data by adding data page without ‘eee’ , error occurs.

I’ve tried your table schema, PHPMaker does not know the uuid() as a function and consider it as string “uuid()”, the field is therefore not detected as auto, so you need to:

  1. Remove the default value “uuid()” from the “Add Page” → “Default Value” column in the Field Setup page,
  2. Uncheck the field from Add page (no need to fill),
  3. Use Row_Inserting server event to set the value, e.g. $rsnew[“eee”] = NewGuid();.

Ok It worked, thank you very much.