Welcome Guest, Not a member yet? Register   Sign In
Simple LEFT JOIN
#1

[eluser]deveye[/eluser]
First Welcome 2 all PHP & CodeIgniter People out there!

Today i've downloaded the framework and it is really cool.

But now i've a question.

I've made a simple request to my database

Code:
$this->db->select('*');
            $this->db->from('pw_entry');
            $this->db->join('pw_address', 'pw_entry.id = pw_address.id', 'left');
            $data['query'] = $this->db->get();

And now i wanted to create a Link to Add addresses to my Adressbook by the Id

Code:
<p>&lt;?=anchor('pw/addresses/'.$row->id, 'Add Addresses');?&gt;</p>

But the Id is only shown by contacts with Addresses in the uri
and when i try to write pw_entry.id i get n error that pw_entry is not known..

can anybody tell me whats my mistake?

cheers, deveye :cheese:
#2

[eluser]Phil Sturgeon[/eluser]
How about a SQL dump from the two tables in question. From what you have posted, the error message could be spot on. Smile
#3

[eluser]deveye[/eluser]
Code:
TABLE 1
ID Name
1  Klaus
2  Dieter

TABLE2
AID ID STREEET   ZIP   COUNTRY
1   1  thisstr.4 24233 Spain
2   1  thisstr.6 32433 Greece

Klaus so has two Addresses and Dieter none. But while i've made a left join the id have to be visible.
Is there a possibility to make a dump with codeigniter or php from the query?
#4

[eluser]deveye[/eluser]
Now i've used a simple trick an Altered the name of the column in the second table.
But if anybody knows how to get the fields with a table name please write it down here.

thx by the way,
deveye




Theme © iAndrew 2016 - Forum software by © MyBB