Welcome Guest, Not a member yet? Register   Sign In
Joining two models with same column names
#1

On CI 4 , when we have 2 Models that are joined betweene but they have same names how can we join them using CI model's

Let's suppose we have

Account [ account_id, name, city_id, updated_at....]
City [ city_id, name, updated_at....]

Here the 2 models have fields name , updated_at ...
When we want to retrieve data how can we do this to avoid conflicts, because when I'm doing it overriding values.

Thank you
Reply
#2

You should be able to specify aliases in a select() method:
$model->select('cities.name AS city_name')...
Reply




Theme © iAndrew 2016 - Forum software by © MyBB