Avoid conflict between column names ? |
I think the best approach is prefix with the table name on foreign keys only, and using SQL aliases for duplicated collumn names. Ex.:
Table user col id col name col age col company_id Table company col id col name col address Code: SELECT So you can get your objects this way: PHP Code: $this->db->select('user.*'); If you prefix your collumns in your db with the table name, even if you make a simple select, you'll have a ugly code like that: PHP Code: echo "$user->user_name, $user->user_age"; At least for me, repeating the table name is annoying and makes my code harder to read. https://www.w3schools.com/sql/sql_alias.asp |
Messages In This Thread |
Avoid conflict between column names ? - by Coool6 - 11-07-2017, 12:38 AM
RE: Avoid conflict between column names ? - by neuron - 11-07-2017, 01:25 AM
RE: Avoid conflict between column names ? - by Coool6 - 11-07-2017, 01:46 AM
RE: Avoid conflict between column names ? - by Coool6 - 11-07-2017, 02:00 AM
RE: Avoid conflict between column names ? - by SomeGuy - 11-08-2017, 08:49 AM
RE: Avoid conflict between column names ? - by ayrtonvwf - 11-07-2017, 03:43 AM
RE: Avoid conflict between column names ? - by PaulD - 11-07-2017, 02:59 PM
RE: Avoid conflict between column names ? - by SomeGuy - 11-07-2017, 08:16 PM
RE: Avoid conflict between column names ? - by PaulD - 11-08-2017, 11:43 AM
RE: Avoid conflict between column names ? - by SomeGuy - 11-09-2017, 10:14 AM
RE: Avoid conflict between column names ? - by soniajessica - 04-19-2022, 08:32 AM
|