Welcome Guest, Not a member yet? Register   Sign In
Does this small piece of code seem ok?
#23

(This post was last modified: 11-04-2015, 10:50 AM by mwhitney.)

Especially compared to all of the discussion about randomness, this is a minor item, but I would generally forego the extra variable and do something like this:

PHP Code:
$check 0;
while (
$check === 0) {
    
$code get_random_string();
    
$check $this->db->where('guest_code'$code)->count_all_results('guests');


or

PHP Code:
do {
    
$code get_random_string();
    
$check $this->db->where('guest_code'$code)->count_all_results('guests');
} while (
$check === 0); 
Reply


Messages In This Thread
Does this small piece of code seem ok? - by PaulD - 10-30-2015, 09:02 AM
RE: Does this small piece of code seem ok? - by mwhitney - 11-04-2015, 10:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB