Welcome Guest, Not a member yet? Register   Sign In
Question with db->join
#1

[eluser]breastfed[/eluser]
Hello

i have a Problem with a db->join Query.
I have a Table "jobs" and "user_profile".

With this model:
Code:
function getJobs ()
    {
            $this->db->join('user_profile', 'jobs.author_id = user_profile.user_id');

            $this->db->limit(4);
            $this->db->order_by('jobs.id','DESC');
            #$this->db->where('membership','2');
            $this->db->where('status','1');
            
            $query = $this->db->get('jobs');
            return $query;
    }

It is kind of working but in my viewer:

Code:
$this->table->set_heading('City','Country', 'Company', 'Time');
    
    foreach($display_jobs->result() as $row):
    
    $this->table->add_row(
        '<a > id.'">'.$row->placeofwork.'</a>',
        '<a > id.'">'.$row->country.'</a>',
        '<a > id.'">'.$row->company_name.'</a>',
        '<a > id.'">Fulltime</a>'
    );
    endforeach;
    echo $this->table->generate();

behind /detail/ it is posting the id of the user_profile Table and not from jobs.

How can i echo the $row->id of the jobs with the company_name of the user_profile?

Looking for urgent help.

Thanks!
#2

[eluser]breastfed[/eluser]
Anybody? Smile
#3

[eluser]Thorpe Obazee[/eluser]
I'm not a user of the table class so I prefer not to answer questions related to it.
#4

[eluser]Maglok[/eluser]
I have been having a similar thing. You can usually use stuff like 'user_profile.company_name' to select a table and a field, but that doesn't seem to work with getting it from the array.

Have you tried assigning a name to it like so:

Code:
SELECT user_profile.company_name comp_name FROM etc

Works in plain SQL Tongue Mabye look into 'AS' SQL command.
#5

[eluser]breastfed[/eluser]
Maglok - thats a good hint, thanks.

But i currently dont know how to realize that Sad

Do you mind to show me a Code Example?

Thank you very much.




Theme © iAndrew 2016 - Forum software by © MyBB