[eluser]cyang[/eluser]
Hey everyone. Just getting started with CodeIgniter, and gotta say I'm having a blast. The term that comes to mind is "controlled chaos", as I can still do whatever I want but have some semblance of order ;-)
Anyways, probably a basic question, but is there some best practice for database-related concurrency? Specifically, I'm implementing an user auth system (actually just using Redux Auth) and want to add a uniqueness check on usernames and emails. Since (hopefully) there might be many registrations at once, I'd imagine a simple database scan followed by insert is a definite race condition. I've thought about using the database class transactions (e.g. $this->db->trans_start()) and also adding a uniqueness constraint directly in the database, but I feel like these will make my app platform dependent (e.g. what if, using MySQL, I want to convert my users table to MyISAM for speed, which I believe doesn't support transactions). Also, I'd then have to rely on catching a database error/exception, and I'd rather validate first, rather than try-and-correct (also not 100% sure how PHP/CI does error handling; I remember it's php4, so no exceptions, right?).
So to sum it up, is there some best-practice for this kind of stuff? Thanks, any help would be greatly appreciated!