Jump to content


Why is it NOT allowed to have 2 fields with the same setRelation value?

setRelation Error GroceryCRUDEnterprise

  • Please log in to reply
3 replies to this topic

#1 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 135 posts
  • LocationPhilippines

Posted 20 June 2018 - 05:47 AM

Hi Everyone!

 

I have a table that has two fields with the same setRelation Value reference.

 

The table structure is:

Table 1: tbldata

Fields:

d_id

d_Data

d_EncodedBy
d_ModifiedBy

 

Table 2: tblperson

Fields:

p_id

p_FirstName

p_LastName

p_Type

 

 

Both f_EncodedBy and f_ModifiedBy of table 1 should be referencing the table 2 through setRelation by:

$crud->setRelation('d_EncodedBy', 'tblperson', '{p_FirstName} {p_LastName}', ['p_Type <> ?'=>'1']);

$crud->setRelation('d_ModifiedBy', 'tblperson', '{p_FirstName} {p_LastName}', ['p_Type <> ?'=>'1']);

But an error is displayed which is as follows:

<p>Type: PDOException</p>
<p>Message: SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'tblperson'</p>
 
Does anyone have the same experience?
Any workaround or ideas regarding this error?
 
Thanks in advance!  :)

 

 

 



#2 Mugs321

Mugs321

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationCanada

Posted 24 June 2018 - 06:15 PM

Just posted what I think is the exact same problem/error/bug(?); linked below. One way I was able to get around the bug was to remove the filter at the end of one of the statements:

 

For example:

$crud->setRelation('d_EncodedBy', 'tblperson', '{p_FirstName} {p_LastName}');

$crud->setRelation('d_ModifiedBy', 'tblperson', '{p_FirstName} {p_LastName}', ['p_Type <> ?'=>'1']);

https://www.groceryc...e-where-clause/



#3 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 135 posts
  • LocationPhilippines

Posted 25 June 2018 - 12:58 AM

Hello Mugs321,

 

Thanks for trying it out.

I already did that but I need both to have filters so that the users won't have to see unneeded data from the drop-down.



#4 Mugs321

Mugs321

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationCanada

Posted 25 June 2018 - 01:53 PM

I already did that but I need both to have filters so that the users won't have to see unneeded data from the drop-down.

 

We need the devs to weigh in.  Pretty sure it's a bug.  I have a few issues with the N2N relationship as well.







Also tagged with one or more of these keywords: setRelation, Error, GroceryCRUDEnterprise

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users