0
votes

I am new to codeigniter I am trying to save my record into the database and when ever I try to do so it gives me this error.

Fatal error: Uncaught ActiveRecord\UndefinedPropertyException: Undefined property: Product->Array in C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Model.php on line 514 in C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Model.php:514 Stack trace: #0 C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Model.php(333): ActiveRecord\Model->read_attribute('Array') #1 C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Validations.php(573): ActiveRecord\Model->__get('Array') #2 C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Validations.php(141): ActiveRecord\Validations->validates_uniqueness_of(Array) #3 C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Model.php(1048): ActiveRecord\Validations->validate() #4 C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Model.php(784): ActiveRecord\Model->_validate() #5 C:\xampp\htdocs in C:\xampp\htdocs\cafe\sparks\php-activerecord\0.0.2\vendor\php-activerecord\lib\Model.php on line 514

The code I have wrote works fine for other models. Here is the code I am using.

$data = array(
            "type" => $this->input->post('type'),
            "code" => $this->input->post('code'),
            "name" => $this->input->post('name'),
            "category" => $this->input->post('category'),
            "cost" => $this->input->post('cost'),
            "description" => $this->input->post('description'),
            "tax" => $this->input->post('tax'),
            "alertqt" => $this->input->post('alertqt'),
            "price" => $this->input->post('price'),
            "color" => $this->input->post('color'),
            "supplier" => $this->input->post('supplier'),
            "unit" => $this->input->post('unit'),
            "taxmethod" => $this->input->post('taxmethod'),
            "options" => $this->input->post('options'),
            "photo" => $image,
            "photothumb" => $image_thumb,
            "created_at" => $date,
            "modified_at" => $date
        );
        $product = Product::create($data);
1

1 Answers

0
votes

I have solved it the issue was not in the controller but it was in the model. I was validating uniqueness of array but actually it was not needed. Removing that block of code works fine.