CodeIgniter Forums
Extracting Data via Model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Extracting Data via Model (/thread-50755.html)



Extracting Data via Model - El Forum - 04-06-2012

[eluser]jzmwebdevelopement[/eluser]
Hey,

What do I put in my model function to enable me to call it from my controller like this:

Code:
$this->model->model_function->value

I currently have:

Code:
public function getCompanyDetails()
{
     $this->db->select('companyName,companySlogan,companyContact,companyEmail,companyWebsite,companyPhone,companyFax,companyAddress');
    
    
    $result = $this->db->get();
    
    return $result->result_array();
}



Extracting Data via Model - El Forum - 04-06-2012

[eluser]InsiteFX[/eluser]
Load the database and your model in your controller!



Extracting Data via Model - El Forum - 04-06-2012

[eluser]jzmwebdevelopement[/eluser]
[quote author="InsiteFX" date="1333772186"]Load the database and your model in your controller!
[/quote]

Opps sorry I have now updated the question I was meaning the model function


Extracting Data via Model - El Forum - 04-06-2012

[eluser]InsiteFX[/eluser]
Controller:
Code:
$data['name'] = $this->model_name->function_name->();



Extracting Data via Model - El Forum - 04-06-2012

[eluser]jzmwebdevelopement[/eluser]
[quote author="InsiteFX" date="1333772905"]Controller:
Code:
$data['name'] = $this->model_name->function_name->();
[/quote]

InsiteFX.

In my controller I have the following line:

Code:
$data['companyName'] = $this->quote->getCompanyDetails->$companyName;
    
    $this->load->view('home', $data);

I am getting Undefined variable in my view

in my model do I have to write
Code:
public function ($field){
for every row that I wish to call from the database?



Extracting Data via Model - El Forum - 04-06-2012

[eluser]InsiteFX[/eluser]
You need to read up on CodeIgniter and Databases because you dont understand anything about it!

CodeIgniter Users Guide - The Database Class