NYCPHP Meetup

NYPHP.org

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

jean-baptiste verrey jeanbaptiste.verrey at gmail.com
Sat Dec 11 08:24:23 EST 2010


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?
2- Otherwise, how do you replicate that in Doctrine ?

Regards,

Jean-Baptiste

ps:
I always thought that this was the best way for the following reason :
- the id is just an integer, so better performance for joins, and searching
for a known user
- the primary key is used to prevent duplicates and when searching
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20101211/1929783b/attachment.html>


More information about the talk mailing list