1
0
mirror of synced 2024-12-16 08:06:02 +03:00
doctrine2/manual/new/docs/en/configuration/levels-of-configuration.txt

34 lines
1.7 KiB
Plaintext
Raw Normal View History

Doctrine has a three-level configuration structure. You can set configuration attributes in 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 user first sets default fetchmode in global level to {{Doctrine::FETCH_BATCH}} and then sets {{example}} table fetchmode to {{Doctrine::FETCH_LAZY}}, the lazy fetching strategy will be used whenever the records of 'example' 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.
2007-06-19 03:53:32 +04:00
In the following example we set an attribute at the global level:
<code type="php">
// setting a global level attribute
$manager = Doctrine_Manager::getInstance();
$manager->setAttribute(Doctrine::ATTR_VLD, false);
2007-06-19 03:53:32 +04:00
</code>
2007-06-19 03:53:32 +04:00
In the next example above we override the global attribute on given connection.
<code type="php">
// setting a connection level attribute
// (overrides the global level attribute on this connection)
$conn = $manager->openConnection(new PDO('dsn', 'username', 'pw'));
$conn->setAttribute(Doctrine::ATTR_VLD, true);
2007-06-19 03:53:32 +04:00
</code>
2007-06-19 03:53:32 +04:00
In the last example we override once again the connection level attribute in the table level.
<code type="php">
// setting a table level attribute
// (overrides the connection/global level attribute on this table)
$table = $conn->getTable('User');
$table->setAttribute(Doctrine::ATTR_LISTENER, new UserListener());
</code>