I had a problem inserting a new row into a database using Doctrine 2 and Codeigniter 2.
I have two tables: languages, categories.
TABLE: CATEGORIES:
id, languages_id, parent_id, title
Detailed table structure - http://pastebin.com/NhULaasc
TABLE: LANGUAGES:
id, title, slug, icon
Detailed table structure - http://pastebin.com/Y6WpzdqF
ENTITIES:
Categories.php - http://pastebin.com/HbpKZGBL
Languages.php - http://pastebin.com/vDEd60NP
modelsLanguagesProxy.php - http://pastebin.com/j6zkeR3J
INSERT PROCEDURE:
$data = $this->input->post(); if( is_array($data) && count($data) ) { unset($data['submit']); $add = new models\Categories(); $add->setLanguage($data['language_id']); $add->setParentId($data['parent']); $add->setTitle($data['title']); $this->em->persist($add); $this->em->flush(); if( $add->getId() ) { $this->session->set_flashdata('message','Kategorija je dodana!'); redirect('admin/kategorije'); }else{ $this->session->set_flashdata('message','Kategorija ni dodana!'); redirect('admin/kategorije'); } }
ERROR:
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'A new entity was found through the relationship 'models \Categories
What am I doing wrong?
source share