Can't load model in controller - php

Since a couple of days I can't load a model in a codeigniter system anymore.
It gives the following error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Clients::$mdl_clients
Filename: controllers/clients.php
Line Number: 48
Controller code:
private function GetAllClients()
{
$this->load->model('clients_model', 'mdl_clients');
$clients = $this->mdl_clients->getClients()->result_array();
return $clients;
}
I read the codeigniter documentation again, and I'am not doing anything wrong that I'am aware of..
Can you guys help me out?

Change the model name by 'clients_model.php' if you dont have, and your class most name 'Clients_model'

It was a weird issue with my server. I uploaded everything to another, and it worked again

Related

whenever using database library,error message is displayed

whenever loading this
$this->load->library('database');
error is shown
Unable to load the requested class: database
without the above mentioned code,the following error is shown.
A PHP Error was encountered
Severity: Notice
Message: Undefined property: LoginPage::$db
Filename: core/Model.php
Line Number: 52
Fatal error: Call to a member function select() on null in
C:\xampp\htdocs\Test_LR\application\models\Login_model.php on line 11
FIle permission From Filezilla...
Connect your FTP client to your web server. In FileZilla, right-click the "system" folder on your web server and choose File Permissions to open the file attributes. Type the correct number in the Numeric Value text field
This means CodeIgniter has a library database.
You can include libraries in two ways:
1) In application/config/autoload.php
Code:
$autoload['libraries'] = array('database'); // Include other libraries here like `session`.
2) Run time by using $this->load->library('database'); if not included with first method.
Without it, it will show fatal error.
Have you tried to use:
$this->load->database();
Instead of $this->load->library('database');
Or double check if your database file available on system
Sample example Usersmodel.php
class usersmodel extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->database();
}
function examplefunction()
{
}
}

How to load two models in the same controller with CodeIgniter?

I've been searching on Internet and on stackoverflow, but i didn't find a solution, or it wasn't the same problem.
I need to load two models in the same controller, and in the same function. One is "model_membre" and the other "model_annonce". It's the name of the class, the file, and the object.
Individually, they work very good, i can access to properties and methods, but when I'm loading the two models, I can't access to the second, regardless of how I load it (autoload, $this->load->model('model_name'), $this->load->model('model_name', 'object_name')).
I simplified to a "test" controller, to see if it was not another part of my code that made the problem :
public function index()
{
$this->load->model('model_membre', 'membre');
$this->load->model('model_annonce', 'annonce');
$liste = $this->annonce->listerEspeces();
$membre = $this->membre->obtenirMembre(1);
}
I tried to changer the order, and the 2nd loaded never works. I get this message :
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Test::$annonce
Filename: controllers/test.php
Line Number: 15
Fatal error: Call to a member function listerEspeces() on a non-object in /homez.604/animalix/beta/application/controllers/test.php on line 15
Please try the following way...
public function index()
{
$this->load->model(array('membre','annonce'));
$liste = $this->annonce->listerEspeces();
$membre = $this->membre->obtenirMembre(1);
}
The models should extend CI_Model and not CI_Controller! This was the source of the problem.

Connecting to the database in a Created Library - CodeIgniter

I have a little issue right now and its bugging me, hopefully one of you guys will be able to help me out.
Basically I'm creating a library to use in CodeIgniter and I'm getting this error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Functions::$db
Filename: libraries/Functions.php
Line Number: 11
The Database library is already on autoload aswell as my functions library:
$autoload['libraries'] = array('database','session','encrypt','functions');
The Functions.php file is located in the application/libraries folder accordingly.
Line number 11 consists of this:
$this->db->where('username', $data);
Not sure as to why the db is an undefined property?
It's probably because you need to get the CI instance first since not everything is loaded yet:
$ci =& get_instance();
$ci->db->where('username', $data);
See if that helps. Also see the instructions here.

Notice: Undefined property: nusoapclient::$operation in /PATH/nusoap.php on line 6837

I got the following error in my nusoap file,
Notice: Undefined property: nusoapclient::$operation in /PATH/nusoap.php on line 6837
Any one got this error and have solution?
I got this error when I was using the "send" method instead of call. It looks like operation gets set when "call" is called, but is not set when send is called by itself.
did this:
$client = new nusoap_client($url);
$client->operation = "SomeOperation";
$client->send($data,$url."/SomeOperation");
At last, I got the correct solution after upgrade the soap version. now the problem is sort over and working well. I did't get the problem again.

Trying to install Auth for CI: Call to undefined method CI_Loader::setdata()

I have been trying to implement an auth system for Codeigniter. I wanted to save time, though it hasn't succeeded so far.
The system I'm trying to implement is: http://codeigniter.com/wiki/auth/
Currently I have some forms working, but the registration form generates a fatal error:
PHP Fatal error: Call to undefined method CI_Loader::setdata() in /Applications/MAMP/htdocs/CI+Login/system/application/controllers/auth.php on line 159
Anyone has an idea what that is about? Anyone has got this system running?
thx.
EDIT:
The code that generates the error is:
if ($this->config->item('auth_use_security_code'))
$this->authlib->register_init();
$data['countries'] = $this->Usermodel->getCountries();
$this->load->setdata($data);
The problem is that load does not contain a method named setdata, has it in a previous version of CI or what can I make of this?
Try this:
$this->load->vars($data);
or remove this line and use the second parameter of the $this->load->view() function.
$this->load->view($this->config->item('auth_register_view'),$data);

Categories