⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Column field is ambiguous in set_relation_n_n



only4viciu
  • profile picture
  • Member

Posted 02 December 2013 - 15:18 PM

Hi guys... 

 

I have this code:

$crud->set_relation_n_n('unitid', 'vehicles_vehicle_unit', 'vehicles_unit', 'vehicleid', 'unitid', 'unitid');

I can see table, but when i try edit or view I will have this error:

Column 'unitid' in field list is ambiguous

SELECT *, unitid as sb890403d FROM (`vehicles_vehicle_unit`) JOIN `vehicles_unit` ON `vehicles_vehicle_unit`.`unitid` = `vehicles_unit`.`unitid` WHERE `vehicleid` = '3506' ORDER BY `vehicles_unit`.`unitid`

The only way to resolve this problem is set table in Select, something like:

 

SELECT *, vehicles_unit.unitid as sb890403d FROM (`vehicles_vehicle_unit`) JOIN `vehicles_unit` ON `vehicles_vehicle_unit`.`unitid` = `vehicles_unit`.`unitid` WHERE `vehicleid` = '3506' ORDER BY `vehicles_unit`.`unitid`

 

It's possible fix this?

 


infinito1971
  • profile picture
  • Member

Posted 08 May 2015 - 16:26 PM

Hi only4viciu,
try changing as follow:
$crud->set_relation_n_n('unitids','vehicles_vehicle_unit','vehicles_unit','vehicleid','unitid','vehicles_unit.unitid','unitid');
 
Best regards,
infinito1971