You are currently reading the 1.2 documentation. Switch to 2.2  2.1  2.0 

Levels of Configuration

Doctrine has a three-level configuration structure. You can set configuration attributes at a global, connection and table level. If the same attribute is set on both lower level and upper level, the uppermost attribute will always be used. So for example if a user first sets default fetchmode in global level to Doctrine_Core::FETCH_BATCH and then sets a table fetchmode to Doctrine_Core::FETCH_LAZY, the lazy fetching strategy will be used whenever the records of that table are being fetched.

  • Global level - The attributes set in global level will affect every connection and every table in each connection.
  • Connection level - The attributes set in connection level will take effect on each table in that connection.
  • Table level - The attributes set in table level will take effect only on that table.

In the following example we set an attribute at the global level:

// bootstrap.php

// ...
$manager->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_ALL);

In the next example above we override the global attribute on given connection:

// bootstrap.php

// ...
$conn->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_NONE);

In the last example we override once again the connection level attribute in the table level:

// bootstrap.php

// ...
$table = Doctrine_Core::getTable('User');

$table->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_ALL);

We haven't introduced the above used Doctrine_Core::getTable() method. You will learn more about the table objects used in Doctrine in the Table section of the next chapter.


Questions and Feedback

If you find a problem with the documentation or have a suggestion, please register and open a ticket.

If you need support or have a technical question, you can post to the user mailing-list.