NYCPHP Meetup

NYPHP.org

[nycphp-talk] Doctrine and auto_increment not being a primary key

John Campbell jcampbell1 at gmail.com
Sat Dec 11 09:49:59 EST 2010


On Sat, Dec 11, 2010 at 9:24 PM, jean-baptiste verrey
<jeanbaptiste.verrey at gmail.com> wrote:
> Hi everyone,
> I started using Doctrine some days ago and realized that the way I was using
> tables was simply not possible ...
> I have always use an integer as auto_increment and do a primary key composed
> by multiple fields such as (with MySQL)
> CREATE TABLE user(
>      id INTEGER(10) not null auto_increment,
>      firstName VARCHAR(32),
>      lastName VARCHAR(32),
>      KEY(id),
>      PRIMARY KEY(firstName,lastName)
> )
> and ... I could not replicate that with Doctrine, which would ask me to have
> the id as a primary key ...
> So I went to Doctrine IRC for a little chat, and ... some guy told me that I
> was completely misunderstanding how a RDBMS worked ...
> I am no expert in SQL but ... this is how all the tables are done in
> OSCommerce...
> So my questions are :
> 1- Am I really not using SQL tables as It should be?

I'll be short, yes, the guy on IRC was giving good advice.   I read
the schema and it says to me:
"All possible users can be uniquely identified by their first and last
name.  There is no chance there will ever be two different people with
the same name.  There is no chance someone might change their name.
Oh, but we will assign everyone a unique number and keep it sorted in
an index, but that is just for fun... we aren't going to use that
number to identify people."   I can't conceive of a situation where
this makes sense.


Regards,
John Campbell



More information about the talk mailing list