Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7175533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:19:04+00:00 2026-05-28T16:19:04+00:00

Im trying to get an max value with codeigniter from an table but it

  • 0

Im trying to get an max value with codeigniter from an table but it isnt working. This is the error i get:

Severity: 4096

Message: Object of class CI_DB_mysql_result could not be converted to
string

Filename: database/DB_active_rec.php

Line Number: 427

This is my function:

public function getPeriodeNummer($bedrijf_id) {
    $this->db->select_max('id');
    $this->db->where('bedrijf_id', $bedrijf_id);
    $result = $this->db->get('rapporten');

    $this->db->select('periode_nummer');
    $this->db->where('rapporten_id', $result);
    $query = $this->db->get('statistieken_onderhoud');

    $data = $query + 1;

    return $data;
}

What im trying to do is as followed:

  1. Select the highest id where bedrijf_id = $bedrijf_id from rapporten.
  2. Select the periode_nummer from statistieken_onderhoud where rapporten_id = the highest id i got from step 1.
  3. Add 1 to the periode_nummer i got from step 2 and return that number.

Thanks in forward for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:19:05+00:00Added an answer on May 28, 2026 at 4:19 pm

    Try

    public function getPeriodeNummer($bedrijf_id) {
        $this->db->select_max('id');
        $this->db->where('bedrijf_id', $bedrijf_id);
        $res1 = $this->db->get('rapporten');
    
        if ($res1->num_rows() > 0)
        {
            $res2 = $res1->result_array();
            $result = $res2[0]['id'];
    
            $this->db->select('periode_nummer');
            $this->db->where('rapporten_id', $result);
            $query = $this->db->get('statistieken_onderhoud');
    
            if ($query->num_rows() > 0)
            {
                $row = $query->result_array();
                $data['query'] = 1 + $row[0]['periode_nummer'];
            }
    
            return $data['query'];
        }
    
        return NULL;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get max value from a 3-d Mat, but minmaxIdx and
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
I'm trying to get the maximum value of an integer field in a table.
I am just trying to get the auto incremented value of a table that
I am trying to get histogram from my color (3-channel) image in OpenCV but
I am using iOS 5.0 and I'm trying to get a value from my
I am trying to get the average and last date row from a table
For example, I am trying to get a min date, a max date, and
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Trying to get my css / C# functions to look like this: body {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.