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

  • Home
  • SEARCH
  • 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 7593363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:09:01+00:00 2026-05-30T21:09:01+00:00

I have setup a doctrine listener which is fired on different database actions and

  • 0

I have setup a doctrine listener which is fired on different database actions and creates a log entity and insert it into the database.

class FOO { 
 // [...]
 public function onFlush(OnFlushEventArgs $args)
 {
     foreach ($args->getEntityManager()->getUnitOfWork()->getScheduledEntityUpdates() as $entity) {
                $this->createLog('edit', $entity);
     }
 }


 private function createLog($action, $entity)
 {
        if ($entity instanceof Log) {
            return;
        }
        $log = new Log;
        $log->setAction($action);
        $log->setTime(new \DateTime);
        $log->setForeignId($entity->getId());
        $log->setUser($this->getUser());
        $t            = explode('\\', get_class($entity));
        $entity_class = strtolower(end($t));
        $log->setEntity($entity_class);
        $this->getEntityManager()->persist($log);
  }
// [...]
}

When I update an object, I get the following error:

SQLSTATE[HY093]: Invalid parameter number: no parameters were bound

In the profiler I see this query:

INSERT INTO vvg_logs (action, entity, foreign_id, user_id, time) VALUES (?, ?, ?, ?, ?)

Parameters: { }

How could I resolve this problem?

UPDATE
Here is my new topic connecting to this question: LINK

  • 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-05-30T21:09:03+00:00Added an answer on May 30, 2026 at 9:09 pm

    Because when onFlush is called, all changes are already calculated and you need to refresh them if you change your entity or create a new entity.

    $em = $this->getEntityManager();
    $uow = $em->getUnitOfWork();
    $logMetadata = $em->getClassMetadata('Your\LogClass');
    ...
    $em->persist($log);
    $uow->computeChangeSet($logMetadata, $log);
    

    For postPersist:

    $em = $this->getEntityManager();
    $uow = $em->getUnitOfWork();
    $log = new Log;
    ...
    
    $logMetadata = $em->getClassMetadata('Your\LogClass');
    $className = $logMetadata->name;
    $persister = $this->getEntityPersister($className);
    $persister->addInsert($log);
    $uow->computeChangeSet($classMeta, $logEntry);
    $postInsertIds = $persister->executeInserts();
    
    if ($postInsertIds) {
        foreach ($postInsertIds as $id => $entity) {
            $idField = $logMetadata->identifier[0];
            $logMetadata->reflFields[$idField]->setValue($entity, $id);
            $this->addToIdentityMap($entity);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have setup multiple SQL Service Broker Queues in a database but have not
I'm working with an existing database schema, and trying to setup two Doctrine models
Entities in symfony 2 have doctrine tags that are preceded with @ORM\ (eg @ORM\Entity).
I have three Doctrine entities: Device, which has a OneToOne relationship with Device\Status, which
I have setup an HTML5 drag and drop upload into my site. The problem
All my Doctrine2 setups are done within YAML files. I have an entity class
I am using Doctrine 1.2 & ZF 1.10. I have my Doctrine CLI setup
I have setup my site with 5 pages which are my menu options. When
I have setup web dav on windows server 2008. It seems to work fine
I have setup a property and implement INotifyPropertyChanged like so... public event PropertyChangedEventHandler PropertyChanged;

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.