I created a new_helper.php and placed my custom functions in it, the file is in 'libraries'
This is the code of the new helper
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('test_method'))
{
function test_method($var = '')
{
return $var;
}
function getPropNum() {
$query = $this->db->query('SELECT * FROM properties');
return $query->num_rows();
}
}
The first function is a test function and it works perfectly when called from the view.
echo test_method('Hello World');
However, the second function is the one that's making errors. It's a simple function to get the number of rows in a table.
Then I loaded the helper inside my controller main.php
$this->load->helper('new_helper');
Then inside my view main_template.php, I called my function
echo getPropNum();
PS: when I call