This is a hard coded behaviour (for example here, but in many places in the code) and you can't change it with the current version. I'm afraid you would either have to patch the library's code or change your db schema.
Is Codeigniter Datamapper other_field must append _id automatically?
-
04-06-2022 - |
Pregunta
I have a problem with Codeigniter Datamapper when Joining table. I have 2 table:
Purchase
purchase_id, ref ...
Stock
stock_id, purchase_ref...
I created a has_many relation :
For purchase:
public $has_many = array(
'stock' => array(
'join_table' => 'stocks',
'other_field' => 'purchase_ref',
'cascade_delete' => TRUE
)
);
For stock:
public $has_one = array(
'purchase'=>array(
'join_other_as' => 'purchase_ref',
'join_table' => 'purchases',
'cascade_delete' => FALSE
)
);
But datamapper seems append _id to the column that I wanna join and it be comes purchase_ref_id and the sql statement becomes something like:
...LEFT OUTER JOIN "stocks" stocks ON "purchases"."id" = "stocks"."purchase_ref_id"...
Is that anyway to avoid appending _id when joining table in datamapper? thx a lot.
Solución
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow