I have a model where I select the correct data from the database, as shown below:
<?php class vacancies extends CI_Model{ function vacancies() { $query = $this->db->query("SELECT * FROM ecc_vacancies_vac WHERE active_vac = 1 AND end_vac >= CURDATE() ORDER BY date_vac DESC"); if($query->num_rows() >= 1){ foreach($query->result() as $row){ $data[] = $row; } return $data; } } }
and a controller for processing this data before sending it for viewing, as shown below:
function index() { //check if there any available vacancies $this->load->model('vacancies'); $data['vacancies'] = $this->vacancies->vacancies(); // then i load the views here }
What I need to do is find out the total number of rows returned here in the controller so that I can send the number to the view so that I can use it later.
When using active entries, I used this line of code:
$data['num_rows'] = $$data['vacancies']->num_rows();
How can I define it in my case?
source share