Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting Additional Field From Different Table
    primarykey
    data
    text
    <p>I saw the <a href="https://stackoverflow.com/questions/12072418/my-model-by-jamie-rumbelow-how-to-use-where-with-the-model"><strong>following post</strong></a> and I'm trying to use it in a way for my queries however I'm using two different tables.</p> <ul> <li>I have my logins table which uses the logins_model and I have the users table.</li> <li>Inside of the logins table it only includes login information needed to log the user in.</li> <li>I currently have the email address as the way for the user to login with the password field.</li> <li>In my users table it includes all the personal information about the user. </li> </ul> <p>What I am wanting to do is when the user logs in successfully, they are sent to the control panel where I query the database for users table for their personal information to display, however I also need the email address to display. </p> <p>I'm trying to figure out how I can gather that email address field when I do the initial query.</p> <p>Here is the <a href="https://github.com/jamierumbelow/codeigniter-base-model" rel="nofollow noreferrer">GitHub repo for MY_Model from Jamie Rumbelow</a>.</p> <p>Does anybody have any suggestions on this? I would certainly appreciate it.</p> <p>I'm hoping someone else can shed some additional insight that has working knowledge of the MY_Model.</p> <p>I've still been battling this all day and would like any other suggestions that anybody will suggest.</p> <p><strong>EDIT :</strong> </p> <p>I've found out that I can can make an additional function however it only puts the email address field into the object instead of the email address with the data from the users table. Is there something I"m doing wrong.</p> <pre><code>$user_data = $this-&gt;user-&gt;with_email_address()-&gt;get_by('user_id', $user_id); public function with_email_address() { $this-&gt;db-&gt;join('logins', 'logins.user_id = users.user_id'); $this-&gt;db-&gt;select('logins.email_address AS email_address'); return $this; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload