You can two tables together by defining a one-to-many or one-to-one relationship.
In this relationship, you define which foreign key links to which table and the column name which is used to display values while adding or editing that entity (in a dropdown).
When the Codeigniter code is automatically generated, it will fetch the appropriate field values and generate the code with the associations.
In the example below, the column from_user_id
in the messages table maps to the primary key ID in the users table and the column used to display the user is first_name
. In the code, the list of users will be fetched in the add and edit controllers so that they are available as a dropdown to be selected.