Pardon the framework specific code. Please just take my word that the objects do what I say they do.
My Code
//Generates a random five digit alphanumerical id
$aliasId = $model->random_id_gen('5');
//calls the active record class for table Person
$person = new Person();
//searches the person table to see if this alias is being used
$search = $person->find('alias=:alias', array(':alias'=>$aliasId));
//if null then it sets an attribute for a another active record class
if ($search==NULL)
{
$model->setAttribute('alias', $aliasId);
$model->setIsNewRecord(TRUE);
}
else
{
//I need to loop through the above code until I find an alias that isn't being used
}
My Question
What do I write in the else
statement to run through the code above until I find an alias that isn't being used in the Person table. My guess is some kind of loop, but I'm just not really sure how to do it. Feel free to re-work this how you like. Put it as its own function/tell me I'm doing it wrong, I won't be offended. Thank you SO!