I am trying to get the maximum value using codeigniter from a table, but it does not work. This is the error I get:
Weight: 4096
Message: object of class CI_DB_mysql_result cannot be converted to a string
File Name: 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 I'm trying to do is the following:
- Select the highest
id where bedrijf_id = $bedrijf_id from rapporten . - Select
periode_nummer from statistieken_onderhoud , where rapporten_id = the highest id obtained from step 1. - Add 1 to
periode_nummer , I got from step 2 and return is a number.
Thank you for your help!
Augus source share