ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

EE Active Record Problem

July 03, 2012 10:49am

Subscribe [2]
  • #1 / Jul 03, 2012 10:49am

    Arazmus

    4 posts

    Hi All,

    I have a simple question for a problem i cannot get my head around:

    this works (returns a result):

    $query = $this->EE->db->query("SELECT hguid AS HGUID
    FROM table
    ORDER BY date DESC
    LIMIT 0 , 1");

    this doesn’t (no results):

    $query = $this->EE->db->select('hguid AS HGUID')->from('table')->order_by('date', 'desc')->limit(0,1)->get();

    Note: I have also tried the none method chaining way and still no luck

    Any Ideas?

     

  • #2 / Jul 03, 2012 7:25pm

    the3mus1can

    426 posts

    It is the order of arguments to the limit() method. It should be:

    ->limit(1, 0)
  • #3 / Jul 04, 2012 4:29am

    Arazmus

    4 posts

    excellent!! no idea why i missed that.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases