Second page... that's why I didn't see anyones messages until I saw
the digest.. I am so lame right now.

On Aug 13, 11:14 am, Anthony <[email protected]> wrote:
> bah, sorry... i didn't notice there was a second page...
>
> On Aug 13, 10:53 am, Anthony <[email protected]> wrote:
>
>
>
> > Thats why they suggested using UUID.  The sun will burn out before you
> > duplicate one of those.
>
> > On the flip side you could use a bigint for a possible
> > 9,223,372,036,854,775,807 products or a regular int will provide you
> > with 2,147,483,647 products. (Values apply to MySQL)
>
> > On Aug 13, 4:24 am, Tomfox Wiranata <[email protected]> wrote:
>
> > > only one....what if all numbers are used? it might take a while but
> > > the time will come
>
> > > On 13 Aug., 11:09, Jeremy Burns | Class Outfit
>
> > > <[email protected]> wrote:
> > > > I don't know the rest of your set up, but auto increment would seem 
> > > > like a really simple solution. It wouldn't need any programming either, 
> > > > which must be a good thing.
>
> > > > You mention re-using numbers - I would guess that re-using a number 
> > > > that previously identified a completely different (and potentially 
> > > > obsolete) product is a bad thing.
>
> > > > On balance, I would say that letting the database assign a new, unique 
> > > > and automatically generated number each time you create a product 
> > > > sounds like the right thing to do - unless there is some rock solid 
> > > > reason why this would break something else.
>
> > > > Jeremy Burns
> > > > Class Outfit
>
> > > > [email protected]http://www.classoutfit.com
>
> > > > On 13 Aug 2010, at 10:04, Tomfox Wiranata wrote:
>
> > > > > so you would suggest auto_increment?
>
> > > > > On 13 Aug., 10:48, Jeremy Burns | Class Outfit
> > > > > <[email protected]> wrote:
> > > > >> The number will rise by 1 on each insert (or attempted insert that 
> > > > >> fails validation at the database level) and once a number has been 
> > > > >> used it is no longer available (although it is possible to do a 
> > > > >> direct insert using SQL, but not really recommended). It isn't 
> > > > >> really possible to reserve numbers ahead of time without doing lots 
> > > > >> of fancy stuff.
>
> > > > >> Reading this whole trail it seems that you are using a sledgehammer 
> > > > >> to crack a nut. I'd keep it simple and let the database do what it 
> > > > >> was born to do.
>
> > > > >> Jeremy Burns
> > > > >> Class Outfit
>
> > > > >> [email protected]http://www.classoutfit.com
>
> > > > >> On 13 Aug 2010, at 09:42, Tomfox Wiranata wrote:
>
> > > > >>> i was under the impression, that it makes trouble, when a product 
> > > > >>> will
> > > > >>> be deleted and the number is free again. will this number then be
> > > > >>> skipped cause auto increment passed it a long time ago?
>
> > > > >>> also i want specific numbers to be reserved. so these ones should be
> > > > >>> left out when auto incrementing...
>
> > > > >>> if those 2 thing wont bother then it would be fine, i guess.
>
> > > > >>> On 13 Aug., 09:46, Jeremy Burns | Class Outfit
> > > > >>> <[email protected]> wrote:
> > > > >>>> What's so wrong with using the (auto incrementing unique) id field 
> > > > >>>> then?
>
> > > > >>>> Jeremy Burns
> > > > >>>> Class Outfit
>
> > > > >>>> [email protected]http://www.classoutfit.com
>
> > > > >>>> On 13 Aug 2010, at 08:39, Tomfox Wiranata wrote:
>
> > > > >>>>> hey sam, thx. the number is sth like a product code. each product 
> > > > >>>>> will
> > > > >>>>> be assigned with a unique number...
>
> > > > >>>>> seems like an alternative, since i am too stupid to make it with 
> > > > >>>>> do
> > > > >>>>> while^^
>
> > > > >>>>> On 13 Aug., 05:22, Sam <[email protected]> wrote:
> > > > >>>>>> Also- I just had an idea... it is kind of janky but I think it 
> > > > >>>>>> will do
> > > > >>>>>> what you want with a good speed increase.
>
> > > > >>>>>> When you get your random number, check if it is already in the
> > > > >>>>>> database by doing the following:
> > > > >>>>>>         $count = $this->find(
> > > > >>>>>>                 'count',
> > > > >>>>>>                 array(
> > > > >>>>>>                         'conditions' => array(
> > > > >>>>>>                                 'Linkable.number' => 
> > > > >>>>>> $randomNumber
> > > > >>>>>>                         )
> > > > >>>>>>                 )
> > > > >>>>>>         );
>
> > > > >>>>>> If $count is not 0 then the number already exists in the 
> > > > >>>>>> database- now
> > > > >>>>>> instead of getting all the db values and looping a bunch of 
> > > > >>>>>> times,
> > > > >>>>>> generate 10 random numbers and put them in an array and do the
> > > > >>>>>> following
>
> > > > >>>>>>         $linkNumbers = $this->find(
> > > > >>>>>>                 'list',
> > > > >>>>>>                 array(
> > > > >>>>>>                         'conditions' => array(
> > > > >>>>>>                                 'Linkable.number' =>
> > > > >>>>>> $randomNumberArray
> > > > >>>>>>                         )
> > > > >>>>>>                 )
> > > > >>>>>>         );
>
> > > > >>>>>> Count the elements in the returned array(count($linkNumbers))- 
> > > > >>>>>> if it
> > > > >>>>>> is less then 10 then at least one of the random numbers you 
> > > > >>>>>> generated
> > > > >>>>>> is not yet in the database- use array_diff to find out which 
> > > > >>>>>> values
> > > > >>>>>> are not in the database and you will be left with an array of 
> > > > >>>>>> good
> > > > >>>>>> random numbers to use:
> > > > >>>>>> $unusedRandomNumbers = array_diff($linkNumbers, 
> > > > >>>>>> $randomNumberArray)
>
> > > > >>>>>> If the $linkNumbers array has 10 elements then just repeat the
> > > > >>>>>> process.
>
> > > > >>>>>> On Aug 12, 7:41 pm, Sam <[email protected]> wrote:
>
> > > > >>>>>>> Can you tell us what you are using this random number for? This 
> > > > >>>>>>> might
> > > > >>>>>>> be a situation where there is an alternative solution that we 
> > > > >>>>>>> could
> > > > >>>>>>> help you out with if we knew why you needed the random numbers. 
> > > > >>>>>>> Also-
> > > > >>>>>>> on the topic of uuid's, aren't they just a hexadecimal number?
> > > > >>>>>>> Couldn't you just convert them to decimal as needed?
>
> > > > >>>>>>> On Aug 12, 3:10 am, Tomfox Wiranata <[email protected]> 
> > > > >>>>>>> wrote:
>
> > > > >>>>>>>> thx to both of you. i know i always do things complicated...
>
> > > > >>>>>>>> so if i do what you suggested, cricket:
>
> > > > >>>>>>>> public function getNewNumber()
> > > > >>>>>>>> {
> > > > >>>>>>>>         do
> > > > >>>>>>>>         {
> > > > >>>>>>>>                 $new_number = rand(10,100000);
> > > > >>>>>>>>         }
> > > > >>>>>>>>         while ($this->_testNewNumber($new_number));
>
> > > > >>>>>>>>         return $new_number;
>
> > > > >>>>>>>> }
>
> > > > >>>>>>>> i'm having an endless loop :(
>
> > > > >>>>>>>> how would my function look like, that is checking for 
> > > > >>>>>>>> existence? cant
> > > > >>>>>>>> believe i am having so much trouble with this....
>
> > > > >>>>>>>> On 12 Aug., 03:35, cricket <[email protected]> wrote:
>
> > > > >>>>>>>>> On Wed, Aug 11, 2010 at 4:45 PM, McBuck DGAF 
> > > > >>>>>>>>> <[email protected]> wrote:
> > > > >>>>>>>>>> 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.
>
> > > > >>>>>>>>> What McBuck said. I've given you a solution but you're 
> > > > >>>>>>>>> implementing it
> > > > >>>>>>>>> in a very strange way. FWIW, this:
>
> > > > >>>>>>>>> while ($eyed = $this->Linkable->validateEyed($lkbl_eyed) ==
> > > > >>>>>>>>> "taken");
>
> > > > >>>>>>>>> is always going to return true. Why are you assigning a value 
> > > > >>>>>>>>> to
> > > > >>>>>>>>> $eyed, which is never used, in any case? That assignment is 
> > > > >>>>>>>>> what is
> > > > >>>>>>>>> screwing things up.
>
> > > > >>>>> Check out the new CakePHP Questions 
> > > > >>>>> sitehttp://cakeqs.organdhelpotherswiththeirCakePHP related 
> > > > >>>>> questions.
>
> > > > >>>>> You received this message because you are subscribed to the 
> > > > >>>>> Google Groups "CakePHP" group.
> > > > >>>>> To post to this group, send email to [email protected]
> > > > >>>>> To unsubscribe from this group, send email to
> > > > >>>>> [email protected] For more options, visit 
> > > > >>>>> this group athttp://groups.google.com/group/cake-php?hl=en
>
> > > > >>> Check out the new CakePHP Questions 
> > > > >>> sitehttp://cakeqs.organdhelpotherswiththeir 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 [email protected]
> > > > >>> To unsubscribe from this group, send email to
> > > > >>> [email protected] For more options, visit this 
> > > > >>> group athttp://groups.google.com/group/cake-php?hl=en
>
> > > > > Check out the new CakePHP Questions 
> > > > > sitehttp://cakeqs.organdhelpotherswith 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 [email protected]
> > > > > To
>
> ...
>
> read more »

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 [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to