question on testing result of update(), insert(), and whether my approach works in ensuring unique data |
[eluser]Cristian Gilè[/eluser]
Hi Chillahan, there is a query helper function in the database class that displays the number of affected rows, when doing "write" type queries such as insert and update: Code: $this->db->affected_rows() If the above function return 0 something went wrong! The quick solution to your problem is to generate unique code on the fly without check the database for uniqueness. You can achieve this using a string like this: Code: CODE = INCREMENTAL_NUMBER + RANDOM_STRING INCREMENTAL_NUMBER is a progressive number stored in DB in a separate table or if you want could be the primary key ID of an existing table. You can encode the number with base64. RANDOM_STRING is a generated random string. The resulting CODE is unique. Cristian Gilè |
Welcome Guest, Not a member yet? Register Sign In |