2

I am trying to get the maximum value of the entry_id within the exp_channel_titles field of an ExpressionEngine2 database using the following code:

ee()->db->select_max('entry_id');
$query = ee()->db->get('exp_channel_titles');
echo "<pre>";
   var_dump($query);
echo "</pre>";

Above code only gives me this:

object(CI_DB_mysql_result)[674]
  public 'conn_id' => resource(45, mysql link)
  public 'result_id' => resource(386, mysql result)
  public 'result_array' => 
    array (size=0)
      empty
  public 'result_object' => 
    array (size=0)
      empty
  public 'current_row' => int 0
  public 'num_rows' => int 1
  public 'row_data' => null

How could I get the actual MAX value from the query?

1 Answer 1

1

This is your solution. Since select_max will only result in one row you will not need to loop through all rows like a normal query. Just use $query->row();

        ee()->db->select_max('entry_id');
        $query = ee()->db->get('exp_channel_titles');

        echo $query->row();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.