>
>Yes, I don't have much experience with dbs yet. But
>I'm working on it. :)
>
That's where we all start! ;-)
>
>I have 1 more question though. :) now that I'm
>thinking about it. the auto_increment value of that id
>column.
>Should I bother about the order of those values.
You should not bother about the auto_increment values. Really, you
shouldn't give them a second thought.
>For example, <PEDANTIC MODE>my table has 10
>records</PEDANTIC MODE>.
>The AUTO_INCREMENT value is 11. I then delete 2 last
>records. I have 8 recs left, and AUTO_INCREMENT value
>is still 11, so I count the rows and add 1. Like this:
>
>$numresults = mysqli_query($link, "SELECT bookmarkId
>FROM bookmark");
>
>$numrows = mysqli_num_rows($numresults);
>$autoIncrement = $numrows + 1;
>$fixAutoIncrementValue = 'alter table bookmark
>AUTO_INCREMENT = '.$autoIncrement.'';
>
>That fixed the AUTO_INCREMENT issue in this situation.
>
Ummm... you're missing the purpose of AUTO_INCREMENT. When you initially
create a new table, define an id column and specify this column to be
auto_increment.
I've been struggling to come up with a really good example of why you
simply shouldn't care *what* the value of an ID value might be, only
that it's unique. So... try this one -
Every car I've ever owned had a license plate. The license plate
uniquely identifies that car in many data bases. No one cares if the
next brand new car sold is issued the next plate number in sequence -
only that each car is uniquely identified.
If I move to a different state and take the car with me, eventually I'll
have to get a new license plate for the new state. The former state
doesn't reuse my old plate number.... I think you can see where this is
going.
The point is, auto_increment simply creates a unique ID. If the ID is for
a car, you might reference the ID in a table of owners, a table of
manufacturers, etc. But there should never be a need or reason to force
the next ID to any particular value - just let the data base assign a
value based on its auto_increment rules.
Mike
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
SPONSORED LINKS
| Php mysql | Job postings |
YAHOO! GROUPS LINKS
- Visit your group "php-list" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
