What is the most correct way around this run Error "Unable to override function"?

I have the following tables:

user, logbook,user_logbook

A user log is a connection table ( isCrossRef="true"in schema.xml) containing foreign keys user_idand logbook_id.

I also wanted to remember the current selected log for any given user, so I placed it current_logbook_idin my table userand gave this foreign key. However, in my file BaseUserQuery.phpI get two functions filterByLogbook().

I know that when you have two foreign keys in one table, you get functions like getUserRelatedBySomething()and from one table getUserRelatedBySomethingElse(), but what is better to do in this situation?

I can, of course, just delete the foreign key and just use the stored identifier, or, I suppose, I could create a new connection table (although this does not seem correct). What is the best thing to do in this situation in terms of “working correctly” in MySQL and Propel (I hope I can do both!).

+5
source share
1 answer

In, schema.xmladd the phpName and refPhpName attributes to the foreign key in the user table definition:

  <table name="user" phpName="User">
    ...
    <foreign-key foreignTable="logbook" phpName="CurrentLogBook" refPhpName="CurrentLogBookUser">
      <reference local="current_logbook_id" foreign="id"/>
    </foreign-key>
    ...
  </table>

Then you need to get a function filterByCurrentLogBook(), and filterByCurrentLogBookUser()not to face.

+2
source

All Articles