I am attempting to operate a simple query with $this->db in Kohana, but am encountering some syntax issues after i use an alias for any table inside my query:

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

It appears in my experience this should work all right. I am proclaiming that "chapter_info" needs to be referred to as "ci," yet this is not taking for whatever reason. The mistake is fairly straight-forward:

There was an SQL error: Table 'gb_data.chapter_info ci' doesn't exist - 
SELECT `ci`.`chapter_id`, `ci`.`book_id`, `ci`.`chapter_heading`, 
       `ci`.`chapter_number`
FROM (`chapter_info ci`) 
WHERE `ci`.`chapter_number` = 1
  AND `ci`.`book_id` = 1

Basically make use of the full table title, instead of an alias, I recieve the expected results without error. This involves me to create a lot more verbose queries, which is not ideal.

Can there be a way to make use of shorter names for tables within Kohana's query-builder?

In Kohana 3 it's just enough:

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

and will also produce the query that consists of:

FROM 'table_name' AS 'alias'

I've examined it and delay pills work. Best of luck.

Use the "as" keyword like ->from("chapter_info as ci"), maybe the query builder will recognize it by doing this.

$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 will work. While you must wrap the initial table title in quotes first prior to the AS keyword and also the new table title you need to shorten it to.