-   Programming (
-   -   doctrine / PHP - how to handle a table that has no PK? (

eantoranz 05-08-2012 12:00 PM

doctrine / PHP - how to handle a table that has no PK?

I'm using doctrine to use an already built DB so that I don't have to go down to the DB level and write as little code as possible.

Here's this table that has no PK. It maps other 2 entities from the project (users to departments, for example) so no PK is really needed on this table.

Of course, I hit the "every entity needs a PK" doctrine requirement and so I'm stuck. I guess I could use a two-field PK but how do I feed it into doctrine?

Thanks in advance.

eantoranz 05-08-2012 12:38 PM

Is it possible to create virtual columns in doctrine? If it is, is it possible to fool doctrine into using them as the PK?

sundialsvcs 05-08-2012 03:44 PM

Make one. You'll be glad you did.

If you need to refer to "a particular column," then you truly do need a key to refer to it. There are plenty of ways to add a unique PK to a table that does not now have one.

I understand perfectly that "you'd rather not." And, I am also-perfectly saying to you now, "oh yes, you do."

eantoranz 05-08-2012 03:59 PM

Perhaps technically it makes sense... but if it gets out of my hands (and it does) I have to find a workaround for it.

All times are GMT -5. The time now is 08:06 AM.