This whole process strikes me as very inefficient. There is no mechanism to prevent your do-while loop from checking the same value an infinite number of times (unless you log each random value and check the next random value against the log AND the db).
I don't know what the purpose of the random value is in your app, but I would suggest an entirely different approach. If you need random values in the range of "min" through "max," you could generate a table ahead of time consisting of the fields id and random_number, with max- min+1 rows. (There are many random number generator sites available, and you might be able to access one of their APIs as needed.) It seems to me that it would be easier to generate these unique values in some random order ahead of time, and then just associate the random_numbers table with your current table through a 1-1 relationship. This process would make it easy to identify the next random number to be assigned, and when the random numbers have been exhausted. Just a thought. On Aug 11, 2:57 pm, Tomfox Wiranata <tomfox.wiran...@gmail.com> wrote: > nabil you are right...i realized it too and returned a string "taken" > or "free"...it works now...... i am saying: > > $eyed = $this->find(array('eyed' => $data), array('eyed')); > if(empty($eyed) == true){ > return "free"; > }else{ > return "taken"; > > and in my controller > > do{ > $lkbl_eyed=rand(1,5); > } > while ($eyed = $this->Linkable->validateEyed($lkbl_eyed) == > "taken"); > return $lkbl_eyed; > } > > now its fine....but an endless loop is created when all numbers are > taken.....he is not ending the loop then...any idea how i can cake to > take a break if all numbers are taken? > > thx Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en