====== Symfony YAML Configuration Reference ====== ===== The databases.yml configuration file ===== In this article we assume that you are familiar with [[http://www.symfony-project.org/reference/1_4/en/02-YAML|The YAML Format]] and [[http://www.symfony-project.org/reference/1_4/en/03-Configuration-Files-Principles|Configuration File Principles]]. The //databases.yml// configuration allows for the configuration of the database connection. It is used by both ORMs bundled with symfony: Propel and Doctrine. The main //databases.yml// configuration file for a project can be found in the //config/// directory. **//Doctrine 1.2//** env_name: conn_name: class: sfDoctrineDatabase file: absolute_path_to_class_file param: dsn: dsn_string username: user_name password: user_password encoding: charset profiler: logging: attributes: quote_identifier: use_native_enum: use_native_set: use_dql_callbacks: decimal_places: default_column_scale idxname_format: index_name_mask seqname_format: sequence_name_mask tblname_format: table_name_mask default_table_type: default_table_collate: collation_name default_table_charset: charset_name export: emulate_database: autoload_table_classes: throw_exceptions: auto_free_query_objects: hydrate_overwrite: cascade_saves: query_class: class_name collection_class: class_name table_class: class_name default_identifier_options: name: id_name type: id_type length: id_length autoincrement: primary: default_column_options: option: value =====Environment and connection===== ====env_name==== The //databases.yml// file is environment-aware, therefore you can add configurations for different environments by specifying environment name (eg.: //prod//, //test//) or '//all//' for all environments. ====env_name > conn_name==== Connection name eg.: //doctrine// =====Connection configuration===== ====env_name > conn_name > class==== PHP class used to create database connection instance. Must extend sfDatabase abstract class. Possible values: //sfDoctrineDatabase// ====env_name > conn_name > file==== Absolute path to the PHP class file which is represented in the class attribute =====Connection parameters===== ====env_name > conn_name > param==== A set of Doctrine connection parameters. These parameters are passed as an array to the constructor of the sfDatabase class instance. ====env_name > conn_name > param > dsn==== Defines data source name (DSN). Doctrine supports both PEAR DB/MDB2 and PDO style data source names. PEAR MDB2 style syntax: driver://username:password@host/database_name PDO style syntax: driver:host=localhost;dbname=database_name The currently supported PDO database drivers are: * //mysql// - MySQL * //mysqli// - MySQL (supports new authentication protocol) (requires PHP 5) * //pgsql// - PostgreSQL * //mssql// - Microsoft SQL Server (NOT for Sybase. Compile PHP --with-mssql) * //oci// - Oracle 7/8/9/10 * //sqlite// - SQLite 2 * //ibase// - InterBase / Firebird (requires PHP 5) * //fbsql// - FrontBase * //querysim// - QuerySim ====env_name > conn_name > param > username==== User name used to connect to database. ====env_name > conn_name > param > password==== Password used to connect to database. ====env_name > conn_name > param > encoding==== The default charset. Default: //UTF8// ====env_name > conn_name > param > profiler==== Indicates whether to output doctrine log to the debug toolbar. The default value of //profiler// depends on the environment. In development environment the default value is //true//, otherwise - //false//. Possible values: //// Default: //sfConfig::get('sf_debug')// ====env_name > conn_name > param > logging==== Specifies whether to enable logging. This option takes effect only when //profiler// is set to //true//. Possible values: //// =====Connection attributes===== ====env_name > conn_name > param > attributes==== This parameter specifies the array of attributes for connection. ====env_name > conn_name > param > attributes > quote_identifier==== Specifies whether to wrap identifiers with quotes. When this attribute is set to //true// all of the field identifiers will be automatically quoted in the resulting SQL statements. Possible values: //// ====env_name > conn_name > param > attributes > use_native_enum==== If you wish to use native enum types for your DBMS if it supports it, then you must set this attribute to //true//. Currently only mysql driver supports this. Possible values: //// Default: //false// ====env_name > conn_name > param > attributes > use_native_set==== If you wish to use native set types for your DBMS if it supports it, then you must set this attribute to //true//. Currently only mysql driver supports this. Possible values: //// Default: //false// ====env_name > conn_name > param > attributes > use_dql_callbacks==== Specifies whether to enable or disable DQL callbacks. Possible values: //// Default: //false// ====env_name > conn_name > param > attributes > decimal_places==== An integer value which specifies the default //scale// for the columns of type //float//, //double// or //decimal//. Default: //2// ====env_name > conn_name > param > attributes > idxname_format==== Specifies the format for index names. This option can be used for changing the naming convention of indexes. By default Doctrine uses the format [name]_idx. So defining an index called //productindex// will actually be converted into //productindex_idx//. Default: //%s_idx// ====env_name > conn_name > param > attributes > seqname_format==== Specifies the format for sequence names. This option can be used for changing the naming convention of sequences. By default Doctrine uses the format [name]_seq, hence creating a new sequence with the name of //mysequence// will lead into creation of sequence called //mysequence_seq//. Default: //%s_seq// ====env_name > conn_name > param > attributes > tblname_format==== Specifies the format for table names. This option can be used for changing the naming convention of tables. Default: //%s// ====env_name > conn_name > param > attributes > default_table_type==== Determines the default type of the table engine will be used in the database for the tables. Use this attribute for MySQL database. Possible values: //// ====env_name > conn_name > param > attributes > default_table_collate==== Specifies the default collation for the tables (eg. utf8_unicode_ci). ====env_name > conn_name > param > attributes > default_table_charset==== Specifies the default character set for the tables (eg. utf8). ====env_name > conn_name > param > attributes > export==== Specifies what Doctrine should export when exporting classes to your database for creating your tables. Available values: * //all// - exports everything (tables and constraints); * //tables// - exporting tables only (but not constraints); * //none// - exports nothing. Use this value if you do not want the table to appear in the database. Possible values: //// Default: //all// ====env_name > conn_name > param > attributes > emulate_database==== Specifies whether or not to emulate databases for Oracle. Possible values: //// ====env_name > conn_name > param > attributes > autoload_table_classes==== Specifies whether or not to load custom Doctrine_Table classes. Possible values: //// Default: //true// ====env_name > conn_name > param > attributes > throw_exceptions==== Specifies whether to throw exceptions when error occurs on Doctrine query execution. Possible values: //// Default: //true// ====env_name > conn_name > param > attributes > auto_free_query_objects==== Specifies whether to auto free query objects after execution. Possible values: //// Default: //false// ====env_name > conn_name > param > attributes > hydrate_overwrite==== Doctrine uses an identity map internally to make sure that multiple objects for one record in a database don't ever exist. If you fetch an object and modify some of its properties, then re-fetch that same object later, the modified properties will be overwritten by default. You can change this behavior by changing the //hydrate_overwrite// attribute to //false//. Possible values: //// Default: //true// ====env_name > conn_name > param > attributes > cascade_saves==== Specifies whether or not to disable the cascading save operations which are enabled by default for convenience. If you set this attribute to //false// it will only cascade and save if the record is dirty. This means that you can't cascade and save records who are dirty that are more than one level deep in the hierarchy, but you benefit with a significant performance improvement. Possible values: //// Default: //true// ====env_name > conn_name > param > attributes > query_class==== Specifies which query class Doctrine should return whenever you instantiate a new query. The only requirement is that it extends the //Doctrine_Query// class. Default: //Doctrine_Query// ====env_name > conn_name > param > attributes > collection_class==== Specifies which collection class Doctrine should use whenever a new collection is instantiated. The only requirement is that it must extend //Doctrine_Collection//. Default: //Doctrine_Collection// ====env_name > conn_name > param > attributes > table_class==== Specifies the class to be returned when using the //Doctrine_Core::getTable()// method. The only requirement is that the class extends Doctrine_Table. This attribute takes effect when //autoload_table_classes// is set to //false//. Default: //Doctrine_Table// =====Default identifier options===== ====env_name > conn_name > param > attributes > default_identifier_options==== Specifies the properties of the automatically added primary key in Doctrine models. Symfony automaticaly generates primary key only if there is no explicitly specified one in the database table schema. ====env_name > conn_name > param > attributes > default_identifier_options > name==== Specifies the name of the identifier column. Default: //id// ====env_name > conn_name > param > attributes > default_identifier_options > type==== Specifies the data type of the identifier column, Default: //integer// ====env_name > conn_name > param > attributes > default_identifier_options > length==== An integer value that specifies the length of identifier column. Default: //8// ====env_name > conn_name > param > attributes > default_identifier_options > autoincrement==== Specifies whether an identifier column is a special identity column in the database that generates a value on insertion of a row. Possible values: //// Default: //true// ====env_name > conn_name > param > attributes > default_identifier_options > primary==== Specifies whether the identifier column is a primary key. Possible values: //// Default: //true// =====Default column options===== ====env_name > conn_name > param > attributes > default_column_options==== Specifies an array of default column options to be used on every column in your model. ====env_name > conn_name > param > attributes > default_column_options > option==== Here you can define any option from the //columns// section of shema.yml file. For example if you want to define a default //scale// and make all columns //not null//, then add //scale// and //notnull// options: all: doctrine: ... param: ... attributes: default_column_options: scale: 8 notnull: true