Part of the EllisLab Network
   
 
ActiveRecord messing up FROM
Posted: 24 October 2008 10:20 AM   [ Ignore ]  
Summer Student
Total Posts:  13
Joined  04-27-2008

Here is my ActiveRecord:

function getScriptures() {
        $this
->db->select('book_id AS vbook, chapter, verse, text, books.name AS book');
        
$this->db->where('books.name', $this->uri->segment(3));
        
$this->db->from('scriptures');
        
$this->db->join('books', 'book_id = books.id', 'inner');
        
$this->db->order_by('chapter', 'asc');
        
$this->db->order_by('verse', 'asc');
        
$query = $this->db->get('scriptures');
        return
$query->result_array();
    
}

Here is the SQL it returns:

SELECT `book_id` AS vbook, `chapter`, `verse`, `text`, `books`.`name` AS book
FROM
(`scriptures`, `scriptures`)
INNER JOIN `books` ON `book_id` = `books`.`id`
WHERE `books`.`name` = 'jude'
ORDER BY `chapter` asc, `verse` asc

That of course returns with this error:

Error Number: 1066
Not unique table
/alias: 'scriptures'

If I take out that second ‘scriptures’ from the FROM field the SQL runs correct in the MySQL Query Browser. I’m posting this in the bug reports because it worked fine until updating.

Profile
 
 
Posted: 29 October 2008 05:19 AM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  4
Joined  10-06-2008

exactly: http://codeigniter.com/forums/viewthread/95148/


Cheers mate!

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120468 Total Logged-in Users: 22
Total Topics: 126547 Total Anonymous Users: 2
Total Replies: 665393 Total Guests: 300
Total Posts: 791940    
Members ( View Memberlist )