CodeIgniter Forums
the Join() and primary field - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: the Join() and primary field (/showthread.php?tid=83434)



the Join() and primary field - Sergio - 09-26-2022

When I use the join() the data returned is mixed.
example:
- [table-one] with field: [id] (primary/autonumber)
- [table-two] with fields: [id] (primary/autonumber), [idTable-one] (index)

The code:
Code:
$mymodel = model(MyModel::class);
$data = $mymodel->join('table-two', 'table-two.id = id', 'left');

in the view file, the array: $data['id'] have the value of table-two, not of table-one.

Why?

Thanks in advance..