Thursday, October 7, 2010

Symfony 1.4 Propel Create Schema From Database And Creating Model

Database Setup
To setup the database, change details in config/databases.yml and propel.ini

If you have multiple tables to generate, then you can create multiple database connections in databases.yml
and instead of
  class: sfPropelDatabase
change to
[connection name]:
  class: sfPropelDatabase

Create Schema From Database
There is a command called php symfony propel:build-schema to help create schema from database. You can refer this from 1.4 reference pdf.

After first running, the CLI has returned an error regarding date.timezone error. This is because in Mac, php.ini is not set by default. You can copy /etc/php.ini.default to /etc/php.ini to configure this according to your timezone.

CLI then returned [propel-schema-reverse] There was an error building XML from metadata: SQLSTATE[HY000] [2002] No such file or directory

This is because in databases.yml and propel.ini, the database host was set as localhost, which generates this error. Change this to

If you have duplicating table names, then change the phpName attribute in the schema files.

Creating Model From Schema
php symfony propel:build-model

php symfony propel:build-form
This will be used later.

No comments:

Post a Comment