[eluser]roryokane[/eluser]
I'm afraid this doesn't work for me. With the code
Code:
$query = $this->db->select('title, description, length(audio), realname, creationdate, podid')->from('podcasts NATURAL JOIN users')->where('userid', $this->uri->rsegment(4) )->get();
I get this error:
Quote:A Database Error Occurred
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'JOIN` users) WHERE `userid` = '4'' at line 2
SELECT `title`, `description`, length(`audio`), `realname`, `creationdate`, `podid` FROM (`podcasts` NATURAL `JOIN` users) WHERE `userid` = '4'
As you can see, the "JOIN" was quoted and "users" was not. Maybe an update of CodeIgniter stopped this from working.
What I'd really like to do, and wish CodeIgniter could do, is say something like
Code:
$this->db->from('podcasts')->join('users', 'NATURAL')
or perhaps even
Code:
$this->db->from('podcasts')->join('users')
I'm having trouble working around this problem without just using $this->db->query(). When I change the middle of the query to
Code:
->from('podcasts')->join('users', 'users.userid = podcasts.userid')
, I get this error:
Quote:A Database Error Occurred
Error Number: 1052
Column 'userid' in where clause is ambiguous
SELECT `title`, `description`, length(`audio`), `realname`, `creationdate`, `podid` FROM (`podcasts`) JOIN `users` ON users.userid = podcasts.userid WHERE `userid` = '4'
, even though I made sure to specify the column names (though stupid MySQL 5.0.41 should be able to realize that the result will be the same after the join).
Can anyone help with either of these problems, or tell me how I would officially request or write myself (for the official release) the modification to join()? (I'm not sure if a bug report is appropriate.)