uuid - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: uuid (/showthread.php?tid=87632) |
uuid - devo - 05-11-2023 hii, how to set uuid as primary key in ci4 ?? database used mysql / postgresql RE: uuid - JustJohnQ - 05-11-2023 What database? What model? What code are you trying? RE: uuid - InsiteFX - 05-11-2023 This may help you understand how MySQL uses the UUID. MySQLTutorial -> MySQL UUID Smackdown: UUID vs. INT for Primary Key RE: uuid - devo - 05-11-2023 (05-11-2023, 10:19 PM)InsiteFX Wrote: This may help you understand how MySQL uses the UUID. oke thank you for the info, but what is the best pratic if i want to integrated uuid as primary key in my database/ model should i custome in callback model before insert? RE: uuid - InsiteFX - 05-11-2023 NOTE: That the MySQL UUID only works with MySQL 8+ For any other version you will need to roll your own methods to handle UUID. Ok, I found this one on MySQL 5.7 in their Blog Archive. MySQL Blog Archive -> Storing UUID Values in MySQL Tables RE: uuid - devo - 05-12-2023 (05-11-2023, 10:46 PM)InsiteFX Wrote: NOTE: That the MySQL UUID only works with MySQL 8+ oke thank you RE: uuid - gosocial2 - 05-13-2023 Here's an implementation (also used by CodeIgniter Wizard): In the database table set the PK field as char(36). E.g. let's assume we have a table named cms_pages whose primary key is a field named uuid and is of type char(36) Create a trait for UUID generation: PHP Code: <?php Example model using the trait: PHP Code: <?php In a custom helper function file (e.g. go_helper.php): PHP Code: if (!function_exists('newUUID')) { RE: uuid - kenjis - 05-13-2023 See https://github.com/michalsn/codeigniter4-uuid |