[eluser]xzela[/eluser]
aha!
I think i got it,
Try this:
Modify your Joes_class file:
Code:
class Joes_class {
var $ci; //defines a place for the instance;
function Joes_class() {
$this->ci =& get_instance(); //get's an instance of the class;
$this->ci->load->database(); //loads the database into the instances;
}
function get_from_database() {
$industry = "SELECT * FROM test_table";
$result = $this->ci->db->query($industry); //call the database method query() within the instance;
return $result->result_array(); //this will return an array;
}
}
I would highly recommend
NOT using this method of getting data from a database. You've just created a model but in a difficult way. Another way to do this would be to use the Model method:
Create a file in the /system/application/model directory called 'industry_model.php';
copy this code into that file
Code:
class Industry_model extends Model {
function Industry_model() {
$this->load->database(); //loads the database class
}
function get_industry() {
$query = $this->db->query('select * from industry where parentid = 0'); //run the query
return $query->result_array(); //returns an array of data
}
}
Now in your Register controller change this line:
Code:
//$this->load->library('Joes_class');
$this->load->model('industry_model');
And to call the get_industry() method, change this line
Code:
//$industry_names = $this->joes_class->get_industry();
$industry_names = $this->industry_model->get_industry();
that should do it.
let me know if anything goes wrong.