I am getting such a warning:
A PHP ERROR WAS ENCOUNTERED
Severity: Warning
Message: Missing argument 1 for User_model::__construct(), called in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\CI_PP\system\core\Loader.php on line 303 and defined
Filename: models/user_model.php
Line Number: 20
while running app in CodeIgniter, NetBeans, PHP 5.4.
This is the code of models/user_model.php(playing around, ignore avoiding OOP principles, please):
<?php
class User_model extends MY_Model {
public $_table = 'pp_user';
public $primary_key = 'u_id';
public $firstname;
public $lastname;
public $emailAddress;
public $password;
public $gender;
public $deliveryAddress;
public $address;
public $city;
public $zip;
public $country;
public $isAdmin;
//this is line nr.20:
public function __construct($firstname, $lastname, $emailAddress, $password, $gender, $address, $deliveryAddress, $city, $zip, $country, $isAdmin) {
parent::__construct();
$this->firstname = $firstname;
$this->lastname = $lastname;
$this->emailAddress = $emailAddress;
$this->password = $password; //TODO!
if ($gender == 'male') {
$this->gender = 0;
} else if ($gender == 'female') {
$this->gender = 1;
} else {
$this->gender = -1;
}
$this->deliveryAddress = $deliveryAddress;
$this->address = $address;
$this->city = $city;
$this->zip = $zip;
$this->country = $country;
$this->isAdmin = $isAdmin;
}
}
I am calling constructor in registration.php(controller):
$firstname = $this->input->post('tf_first_name');
$lastname = $this->input->post('tf_last_name');
$emailAddress = $this->input->post('tf_email_address');
$password = $this->input->post('tf_password_base');
$gender = $this->input->post('tf_gender');
$address = $this->input->post('tf_address');
$deliveryAddress = $this->input->post('tf_delivery_addres');
$city = $this->input->post('tf_city');
$zip = $this->input->post('tf_zip');
$country = $this->input->post('tf_country');
$isAdmin = FALSE;
$user_instance = new User_model(
$firstname,
$lastname,
$emailAddress,
$password,
$gender,
$address,
$deliveryAddress,
$city,
$zip,
$country,
$isAdmin);
If I change contor arguments from:
public function __construct($firstname, $lastname, $emailAddress, $password, $gender, $address, $deliveryAddress, $city, $zip, $country, $isAdmin)
to:
public function __construct($firstname="", $lastname="", ...) {
then it works, but I do not like such a solution. I have been searching for a hints all over the web but according to PHP OOP tutorials and PHP manual it looks ok.
Loader.php on line 303 is doing this:
$CI->$name = new $model();
I tried to changed parameters to direct ones when instantiating object, I tried to remove relation to parent class but the problem remains the same.
I am really curious what might be the problem, any idea?