TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Kohana ORM question
  • I have the following query, which contains a count:

    SELECT news.Title, news.Contents, news.PostDate, news.Deleted, account.AccountName, count(idComment)
    FROM news
    INNER JOIN account
    ON news.idAccount = account.idAccount
    LEFT JOIN comment
    ON comment.idNews = news.idNews
    GROUP BY
    news.idNews
    

    I was wondering if this could be done through the ORM, or if it would be easier to just use the query builder. The part I'm having difficulty with is the count(idComment).

  • Found a solution:

    DB::expr('COUNT("idComment")')

    appears to work.

  • thats the right thing to do. DB::expr doesn't do any escaping.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion