Jump to content


Error when using both set_relation_n_n and set_relation to the same table.

set_relation set_relation_n_n

  • Please log in to reply
1 reply to this topic

#1 jjwdesign

jjwdesign

    Member

  • Members
  • PipPip
  • 12 posts

Posted 08 May 2013 - 08:07 PM

Has anyone seen this error when trying to use both set_relation_n_n() and set_relation() to the same table?

 

I've got a 1-to-many and a many-to-many relationship to a 'contacts' table that I need to define. The many-to-many is for partners contacts and the 1-to-many is for a related vendor.

 

$crud->set_relation('vendor_id', 'contacts', '{contacts.first_name} {contacts.last_name} ({contacts.company})');

$crud->set_relation_n_n('contacts', 'collections_contacts', 'contacts', 'collection_id', 'contact_id', '{contacts.first_name} {contacts.last_name} ({contacts.company})', 'priority');

 

The column names seem to be prefixed with the table name and the "as" name. Note: j96b1f972.contacts.first_name

 

Error Number: 1054

Unknown column 'j96b1f972.contacts.first_name' in 'field list'

SELECT `collections`.*, CONCAT('', COALESCE(j96b1f972.contacts.first_name, ''), ' ', COALESCE(j96b1f972.contacts.last_name, ''), ' (', COALESCE(j96b1f972.contacts.company, ''), ')') as s96b1f972 FROM (`collections`) LEFT JOIN `contacts` as j96b1f972 ON `j96b1f972`.`id` = `collections`.`vendor_id`

I assume I could just create my own custom field dropdown for the "vendor_id" field as it's not as special as the many-to-many relationship. Any suggestions?

 



#2 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 08 May 2013 - 09:31 PM

Interesting. I will try to reproduce it to see what happens.

But if you can get away with using a custom dropdown do it.

Use the field_type function.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users