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 6221295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:06:26+00:00 2026-05-24T08:06:26+00:00

I am playing with Doctrine 2 and PHPUnit and of course, something goes wrong

  • 0

I am playing with Doctrine 2 and PHPUnit and of course, something goes wrong sometimes. That’s what unittesting is all about. But when I get a PDOException for one reason or the other, I don’t get to see the query that is causing it. Example:

$ phpunit --group database
PHPUnit 3.5.14 by Sebastian Bergmann.

E

Time: 2 seconds, Memory: 14.75Mb

There was 1 error:

1) My\Tests\Entity\MyMappingTest::testLoad
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't11.id' in 'on clause'

/usr/local/svn/php5/libraries/Doctrine/DBAL/Connection.php:613
/usr/local/svn/php5/libraries/Doctrine/ORM/Persisters/BasicEntityPersister.php:569
/usr/local/svn/php5/libraries/Doctrine/ORM/Persisters/BasicEntityPersister.php:624
/usr/local/svn/php5/libraries/Doctrine/ORM/UnitOfWork.php:1979
/usr/local/svn/php5/libraries/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php:139
/usr/local/svn/php5/libraries/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php:44
/usr/local/svn/php5/libraries/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php:99
/usr/local/svn/php5/libraries/Doctrine/ORM/Persisters/BasicEntityPersister.php:580
/usr/local/svn/php5/libraries/Doctrine/ORM/EntityRepository.php:130
/usr/local/svn/php5/libraries/Doctrine/ORM/EntityManager.php:350


FAILURES!
Tests: 1, Assertions: 1, Errors: 1.

That’s all fine and dandy, but how do I tell Doctrine or PHPUnit to give me the SQL query that is causing this exception so that I have any hope of debugging it? Right now, this exception is kind of useless. I tried var_dumping the exception object but that just recurses forever. Surely I should be able to tell Doctrine to give me more information?

  • 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-24T08:06:27+00:00Added an answer on May 24, 2026 at 8:06 am

    You could enable native Doctrine SQL logging, or with a bit more effort you could implement Doctrine\DBAL\Logging\SQLLogger to store the last query and override PHPUnit_Framework_TestCase::onNotSuccessfulTest() to add it a new exception in the case of a PDOException. Unfortunately, you’ll lose the original stack trace, but PHP doesn’t allow changing an exception’s message once it’s created. 🙁

    Use setSQLLogger() on the config object to use your logger. Do this in PHPUnit bootstrap.php and make it available to your test case base class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When playing a sound using e.g: sound(x,fs); I sometimes by accident play the wrong
Im playing about with the django auth library, and ive come across something i
Playing with Git and GitHub,I found that sometimes a git commit -a is needed
Playing with Disqus for commenting, but the problem is that we have a Silverlight
I playing around with a function that I want to bind to all the
I'm using symfony 1.4 and doctrine. I've spent the last couple days playing with
Playing with the new(ish) url rewriting functionality for web forms, but I'm running into
Playing with jquery for the first time, and I'm trying to get a simple
Playing around with MongoDB and NoRM in .NET. Thing that confused me - there
While playing around with regexps in Scala I wrote something like this: scala> val

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.