Welcome Guest, Not a member yet? Register   Sign In
ActiveRecord messing up FROM
#1

[eluser]Jonathan McGaha[/eluser]
Here is my ActiveRecord:

Code:
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:
Code:
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:
Code:
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.
#2

[eluser]Josip Jelic[/eluser]
exactly: http://ellislab.com/forums/viewthread/95148/


Cheers mate!




Theme © iAndrew 2016 - Forum software by © MyBB