views:

50

answers:

2

I'm following the documentation almost word for word, except for two adjustments which I believe are corrections.

First adjustment: I eliminate the redundant DIRECTORY_SEPARATOR in system/application/doctrine.php:

//this produces "...system/application//fixtures"
$config = array('data_fixtures_path'  =>  dirname(__FILE__) . DIRECTORY_SEPARATOR . '/fixtures',

//Replaced with:
$config = array('data_fixtures_path'  =>  dirname(__FILE__) . DIRECTORY_SEPARATOR . 'fixtures',

The resulting paths appear correct.

Second adjustment: The generated models (e.g. models/User.php) don't seem to load the base models that extend Doctrine_Record, so I add an explicit require() call to each model like so:

require('generated/BaseUser.php');

class User extends BaseUser { ... }

So, my current problem: When it comes time to build the tables for the first time:

$ ./doctrine build-all-reload
build-all-reload - Are you sure you wish to drop your databases? (y/n)
y
build-all-reload - Successfully dropped database for connection named 'mydb'
build-all-reload - Successfully created database for connection named 'mydb'
build-all-reload - Created tables successfully
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mydb.user' doesn't exist

Doctrine seems to happily empty tables, drop tables, drop databases, and create databases, but I can't figure out why it won't create tables. It clearly says Created tables successfully, but SHOW TABLES; returns "No tables found in database."

Doctrine is using the same MySQL user that I am, which has ALL PRIVILEGES.

Any ideas why Doctrine can't create tables? Hopefully I'm just blind and/or dumb.

Alternatively, is there I way I can just produce a file of SQL CREATE statements based on my yaml schema or models that I can run on my own to debug this issue?

A: 

Maybe table name "user" can be a reason in this specific case. Try to set other name for table.

Aliaksei Shytkin
Alright, I just tried `$this->setTableName('asdf');` and got `Base table or view not found: 1146 Table 'mydb.asdf' doesn't exist`. The database still doesn't have any tables.
Dolph
Try to execute task ./doctrine build-sql (I don't remember exact name). It generates file with plain sql, which create tables. Next you will be able to decide is it wrong in sql or in doctrine.
Aliaksei Shytkin
It generated `sql/schema.sql` which was an empty file... odd, because it's obviously aware of my yaml and models?
Dolph
A: 

Maybe you have already done it but not mentioning it but you MAY be missing all the required "loading" commands. Using require is not the best solution here.

Doctrine_Core::loadModels(realpath(dirname(__FILE__) . '/..') . DIRECTORY_SEPARATOR . 'models');

This needs to be done for each directory that holds Doctrine related model files (models, basemodels, tables,...) since it does not work recursively. I had the very same problem and defining loadModels for each of my directories did the trick.

DrColossos