Re: Mysql Rows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



----- Original Message ----- 
From: "benifactor" <snorris17@xxxxxxx>
To: "Robert Cummings" <robert@xxxxxxxxxxxxx>; "tedd" <tedd@xxxxxxxxxxxx>
Cc: "PHP-General" <php-general@xxxxxxxxxxxxx>; "Murray @ PlanetThoughtful"
<lists@xxxxxxxxxx>; "Anthony Ettinger" <aettinger@xxxxxxxxxxxxxx>
Sent: Saturday, March 04, 2006 2:29 PM
Subject: Re:  Mysql Rows


>
> ----- Original Message ----- 
> From: "Robert Cummings" <robert@xxxxxxxxxxxxx>
> To: "tedd" <tedd@xxxxxxxxxxxx>
> Cc: "PHP-General" <php-general@xxxxxxxxxxxxx>; "benifactor"
> <snorris17@xxxxxxx>; "Murray @ PlanetThoughtful" <lists@xxxxxxxxxx>;
> "Anthony Ettinger" <aettinger@xxxxxxxxxxxxxx>
> Sent: Saturday, March 04, 2006 9:41 AM
> Subject: Re:  Mysql Rows
>
>
> > On Sat, 2006-03-04 at 09:14, tedd wrote:
> > > planetthoughtful  wrote:
> > >
> > > >But, too often I've seen people new to database design not liking
> > > >'gaps' because 'user1' will have a unique id of '1', while 'user2'
> > > >will have a unique id of '6' because the records associated with
> > > >unique ids '2' through '5' were deleted during testing, and so on.
> > > >So, they feel that 'user2' should have a unique id of '2', ignoring
> > > >the fact that that's not a unique id at all, if you had id '2'
> > > >associated with another record at some point.
> > >
> > > And, Anthony wrote:
> > >
> > > >I remember the days where i'd
> > > >clear a database after testing to keep the auto_increment inline, but
> > > >eventually, you will get out of sync on that, so it's not a reliable
> way of
> > > >keeping a numerical sequence.
> > >
> > > Well... I'm one of those people who don't like gaps. I understand
> > > that if the dB is relational, then you shouldn't be concerned about
> > > gaps. Gaps are only perceived from a perspective of an artificial
> > > ordering system -- who knows where the data actually is in memory or
> > > on disk.
> > >
> > > However, when I'm working with a flat dB and want to step through the
> > > records to do editing, I like the records to be in order based upon
> > > an "id" (i.e., Record 1, Record 2, Record 3, and so on). I use an
> > > auto_increment unique "id"  for this.
> > >
> > > It's not a big problem for me to keep the records in order either.
> > > Whenever I delete a record, I simply follow with:
> > >
> > > $dbQuery = "ALTER TABLE $dbtable ";
> > > $dbQuery .= "DROP id, ";
> > > $dbQuery .= "ADD id INT UNSIGNED NOT NULL AUTO_INCREMENT,";
> > > $dbQuery .= "AUTO_INCREMENT = 1";
> > > $result = mysql_query($dbQuery) or die("2. Could not renumber dB
> > > $dbQuery" . mysql_error());
> >
> > *LOL* I knew those MySQL people shouldn't have made the ALTER TABLE
> > syntax available to just anyone. Gun --> foot --> *BLAM*. I hope to God
> > you never get your hands on a real database with millions of entries.
> >
> > Cheers,
> > Rob.
> > -- 
> > .------------------------------------------------------------.
> > | InterJinn Application Framework - http://www.interjinn.com |
> > :------------------------------------------------------------:
> > | An application and templating framework for PHP. Boasting  |
> > | a powerful, scalable system for accessing system services  |
> > | such as forms, properties, sessions, and caches. InterJinn |
> > | also provides an extremely flexible architecture for       |
> > | creating re-usable components quickly and easily.          |
> > `------------------------------------------------------------'
> >
>
> my reasoning for needing the users number in a database is this...
>
> i am going to be doing a lottery type thing where i grab a random number
> between 1 and the result of mysql_num_rows($result)... that is the reason
> the gaps matter.  the while loop didn't work for me so if anyone could
help
> me out on how to get this number i would aprreaciate it. thank you in
> advance.

here is what i tried..
while ($d = mysql_fetch_array($query)) {
$i = 0;
while ($d[username] != $user) {
$i++
}
}
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux