How to insert UUID in CodeIgniter

Universal Unique Identifier (UUID) in MySQL is used as row identity value (PRIMARY KEY). It is unique in every database, so you can merging records from different databases.

If you are working in CodeIgniter and want to insert UUID as row PRIMARY KEY, use the following sample code to insert UUID into MySQL table. UUID() function generate a 128-bit number which is globally unique in space and time.

//set multiple column values
$data = array(
'name' => 'CodexWorld',
'email' => '',
'mobile' => '8888888888'

//set id column value as UUID

//insert all together

Leave a reply

CodexWorld Newsletter

Subscribe CodexWorld updates via email and get every new post delivered to your inbox.