Hi,


I have a 1:m relationship between Subitem and SubitemColor. Now I would 
like to save some data inside an onFlush to modify some data for 
SubitemColor. The problem: I get the error message below when executing the 
controller you can see below too: 

An exception occurred while executing 'INSERT INTO SubitemColor (code, 
precio, pvp_recommended, file_name, activado, en_stock, area, 
lets_fix_width_or_height_in_list, lets_fix_width_or_height_in_show, 
position_level_0, position_level_1, position_brand, subitem_id, color_id) 
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [2]:

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does 
not match number of tokens

 

  public function onFlush(Event \OnFlushEventArgs $eventArgs)
  {
    $em = $eventArgs->getEntityManager();
    $uow = $em->getUnitOfWork();

    $updates = $uow->getScheduledEntityUpdates();
    $insertions = $uow->getScheduledEntityInsertions();

    /////////// NEW SUBITEM_IMAGE OR SUBITEM_COLOR UPLOADED //////////
    foreach ($insertions as $entity) {


      if ($entity instanceof SubitemColor) {
        //$entity->setLetsFixWidthOrHeightInList("jander");
        //$entity->setLetsFixWidthOrHeightInList('width');
        //$entity->setLetsFixWidthOrHeightInShow('width');

        $entity->setEnStock(2);

        $metaSubitemColor = $em->getClassMetadata(get_class($entity));

        $uow->computeChangeSet($metaSubitemColor, $entity);

        $uow->persist($entity);
      }
    }
  }
//controller - controller - controller - controller
    $subitem = new Subitem();

    $em = $this->getDoctrine()->getManager();

    $subitem->setNombre("jls");
    $subitemColor = new SubitemColor();
    $subitem->addSubitemColor($subitemColor);

    $em->persist($subitem);
    $em->persist($subitemColor);

    $metaSubitem = $em->getClassMetadata(get_class($subitem));
    $em->flush();

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to