Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2: Base table or view not found: 1146

Problem

Hi, I"m working with a friend on a Symfony2 project. He's working on a Windows based computer and I'm on my Mac. We setup the project and made the database model / entities (code first) on his computer. Now I wanted to start working on it as well so we did a SQL dumb to my localhost. I edited the parameters.yml to match my settings. The project can connect to the server. But when I try to open a page where the database is used i get this error:

An exception occurred while executing 'SELECT t0.id AS id1, t0.name AS name2, t0.bigimage AS bigimage3, t0.smallimage AS smallimage4, t0.info AS info5, t0.city_id AS city_id6 FROM District t0':

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'socialgeogroep6.District' doesn't exist 500 Internal Server Error - DBALException 1 linked Exception: PDOException »

Just to be clear, the page is running normal on his computer; he gets the data as it should be.


Question

What can be the problem? I looked in my PHPmyAdmin over and over again and the database is there with all the fields and data...
(screen: http://gyazo.com/4a0e5f1ee6b1e29d2d277df5fc0d8aac) I really can't imagine what the problem is.

I hope someone can help us!

like image 564
YP_be Avatar asked Jan 17 '13 13:01

YP_be


4 Answers

This work for my in symfony 2.7. Just put in config.yml:

doctrine:
    # ...
    orm:
        # ...
        entity_managers:
            default:
                naming_strategy: doctrine.orm.naming_strategy.underscore
like image 50
abdiel Avatar answered Oct 07 '22 00:10

abdiel


It's likely a case issue. You have the district table on your database, but doctrine is asking for the District table.

You should configure doctrine to use lower case table name. Refer to the doctrine documentation http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#persistent-classes to know how to do so.

like image 41
AdrienBrault Avatar answered Oct 07 '22 01:10

AdrienBrault


I just had exactly the same kind of problem because i'm writing code on windows and i need to deploy on linux.

The solution is to add in config.yml the line:

doctrine:
    orm:
        naming_strategy: doctrine.orm.naming_strategy.underscore
like image 21
Andrew Starlike Avatar answered Oct 06 '22 23:10

Andrew Starlike


Table name case issue

socialgeogroep6.District

It should be socialgeogroep6.district as per the screenshot. Check the Entity annotation.

like image 25
Venu Avatar answered Oct 07 '22 01:10

Venu