LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   doctrine / PHP - how to handle a table that has no PK? (http://www.linuxquestions.org/questions/programming-9/doctrine-php-how-to-handle-a-table-that-has-no-pk-943906/)

eantoranz 05-08-2012 11:00 AM

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

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 11:38 AM

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 02: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 02: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 03:03 PM.