Using a table-alias in Kohana queries? Using a table-alias in Kohana queries? database database

Using a table-alias in Kohana queries?


In Kohana 3 it is simply enough:

->from( array('table_name', 'alias') )

and this will create the query that contains:

FROM 'table_name' AS 'alias'

I have tested it and it works. Good luck.


$result = $this->db  ->select("ci.chapter_id, ci.book_id, ci.chapter_heading, ci.chapter_number")  ->from("'chapter_info' AS ci")  ->where(array("ci.chapter_number" => $chapter, "ci.book_id" => $book))  ->get();

That should work. As you must wrap the original table name in quotes first before the AS keyword and the new table name you want to shorten it to.


Try using the "as" keyword like ->from("chapter_info as ci"), maybe the query builder will recognize it this way.