Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8066493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:00:54+00:00 2026-06-05T12:00:54+00:00

In doSave() function in form I’m trying to save article category (which it is

  • 0

In doSave() function in form I’m trying to save article category (which it is a node in a tree), and then assign to this category articles (many to many relationship).
I’m getting an error while in $this->saveWaArticleNewsCategoryMapList($con); line. (Project is builded on symfony 1.4.16). There is no error when I assign article to an existing category.

public function doSave($con = null) {

$scope = $this->getValue('tree_scope');
$toEdit = $this->getObject();
if ($toEdit->isNew()) {
    $node = new ArticleCategory();
    $node->setBrandId($this->getValue('brand_id'));
    $node->setName($this->getValue('name'));
    $node->setTreeScope($scope);

    $root = ArticleCategoryQuery::create()->findRoot($scope);
    if ($root == null) {
        $root = new ArticleCategory();
        $root->setName('Root');
        $root->setTreeScopeIdValue($scope);
        $root->makeRoot();
        $root->save($con);

        $node->insertAsLastChildOf($root);
        $node->save($con);
        return;
    }
    $parent = ArticleCategoryQuery::create()->findPk($this->getValue('parent_id'));
    $node->insertAsLastChildOf($parent);
} else {
    $node = ArticleCategoryQuery::create()->findOneByArticleCategoryId($toEdit->getArticleCategoryId());
    $node->setBrandId($this->getValue('brand_id'));
    $node->setName($this->getValue('name'));
    if ($toEdit->getParent()->getArticleCategoryId() != $this->getValue('parent_id')) {
        $parent = ArticleCategoryQuery::create()->findPk($this->getValue('parent_id'));
        $node->moveToLastChildOf($parent);
    }
}
$node->save($con);
$this->saveArticleNewsCategoryMapList($con); <--Error
$this->saveArticleHelpCategoryMapList($con);
}

Error:

Unable to execute INSERT statement [INSERT INTO `article_news_category_map` (`ARTICLE_ID`) VALUES (:p0)] [wrapped: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`projectname`.`article_news_category_map`, CONSTRAINT `article_news_category_map_FK_2` FOREIGN KEY (`category_id`) REFERENCES `article_category` (`article_category_id`) ON DELETE CASCADE)]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:00:56+00:00Added an answer on June 5, 2026 at 12:00 pm

    Updating ArticleCategoryId in object solved the problem:

    $node->save($con);
    $this->getObject()->setArticleCategoryId($node->getArticleCategoryId());
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to override my form like this: protected function doSave($con = null) {
Hi, I am trying to save data using web services, jquery and json. From
I trying to create a extension for a browser and i want do save
I have a form, with a bunch of fields, and then I have a:
I have an option in my form which if the user answer yes would
I have a form which has three inputs when the page loads -- 2
when on button click this function is called save_edit: function() { this.do_save(); }, I
I have an editor class which extends FormEditor class. In order to achieve save
Using Symfony 1.4.5 with Doctrine I have a model which includes an uploaded image
Is there a simple way to (in VIM) do save the currently open file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.