Codeigniter - Doctrine inserting error - Many To One relation

半腔热情 提交于 2019-12-10 12:16:13

问题


I am having a problem with inserting a new row in 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#languages' that was not configured to cascade persist 
operations for entity: @. Explicitly persist the new entity or 
configure cascading persist operations on the relationship.... 

What am I doing wrong?


回答1:


I've solved the problem.

My full solution: https://gist.github.com/1338884



来源:https://stackoverflow.com/questions/7985676/codeigniter-doctrine-inserting-error-many-to-one-relation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!