Commit 5f05818c authored by zYne's avatar zYne

Docs updated Session -> Connection

parent 6fffa9e6
Creating a new listener is very easy. You can set the listener in global, session or factory level.
Creating a new listener is very easy. You can set the listener in global, connection or factory level.
When the validation attribute is set as true all transactions will be validated, so whenever Doctrine_Record::save(),
Doctrine_Session::flush() or any other saving method is used all the properties of all records in that transaction will have their values
Doctrine_Connection::flush() or any other saving method is used all the properties of all records in that transaction will have their values
validated.
<br \><br \>
Validation errors are being stacked into Doctrine_Validator_Exception.
Whenever you fetch records with eg. Doctrine_Table::findAll or Doctrine_Session::query methods an instance of
Whenever you fetch records with eg. Doctrine_Table::findAll or Doctrine_Connection::query methods an instance of
Doctrine_Collection is returned. There are many types of collections in Doctrine and it is crucial to understand
the differences of these collections. Remember choosing the right fetching strategy (collection type) is one of the most
influental things when it comes to boosting application performance.
......
Doctrine_Manager is the heart of every Doctrine based application. Doctrine_Manager handles all sessions (database connections).
Doctrine_Manager is the heart of every Doctrine based application. Doctrine_Manager handles all connections (database connections).
Switching between sessions in Doctrine is very easy, you just call Doctrine_Manager::setCurrentSession() method.
You can access the session by calling Doctrine_Manager::getSession() or Doctrine_Manager::getCurrentSession() if you only
want to get the current session.
Switching between connections in Doctrine is very easy, you just call Doctrine_Manager::setCurrentConnection() method.
You can access the connection by calling Doctrine_Manager::getConnection() or Doctrine_Manager::getCurrentConnection() if you only
want to get the current connection.
In order to get your first application started you first
need to get an instance of Doctrine_Manager which handles all the sessions (database connections).
The second thing to do is to open a new session.
need to get an instance of Doctrine_Manager which handles all the connections (database connections).
The second thing to do is to open a new connection.
......@@ -5,4 +5,4 @@ inheritance (including column aggregation inheritance).
So instead of writing lots of SQL inner and outer joins, unions and subselects yourself,
you can write simple DQL queries where relationships are being referenced with dot-notation.
<br \><br \>
You can execute DQL queries with Doctrine_Session::query() method.
You can execute DQL queries with Doctrine_Connection::query() method.
You can retrieve existing objects (database rows) with Doctrine_Table or Doctrine_Session.
You can retrieve existing objects (database rows) with Doctrine_Table or Doctrine_Connection.
Doctrine_Table provides simple methods like findBySql, findAll and find for finding objects whereas
Doctrine_Session provides complete OQL API for retrieving objects (see chapter 9).
Doctrine_Connection provides complete OQL API for retrieving objects (see chapter 9).
There are couple of ways for creating new records. Propably the easiest is using
native php new -operator. The other ways are calling Doctrine_Table::create() or Doctrine_Session::create().
native php new -operator. The other ways are calling Doctrine_Table::create() or Doctrine_Connection::create().
The last two exists only for backward compatibility. The recommended way of creating new objects is the new operator.
Deleting records in Doctrine is handled by Doctrine_Record::delete(), Doctrine_Collection::delete() and
Doctrine_Session::delete() methods.
Doctrine_Connection::delete() methods.
Doctrine provides many ways for record retrieval. The fastest ways for retrieving existing records
are the finder methods provided by Doctrine_Table. If you need to use more complex queries take a look at
DQL API and Doctrine_Session::query method.
DQL API and Doctrine_Connection::query method.
Updating objects is very easy, you just call the Doctrine_Record::save() method. The other way
(perhaps even easier) is to call Doctrine_Session::flush() which saves all objects. It should be noted though
(perhaps even easier) is to call Doctrine_Connection::flush() which saves all objects. It should be noted though
that flushing is a much heavier operation than just calling save method.
Creating new record (database row) is very easy. You can either use the Doctrine_Session::create() or Doctrine_Table::create()
Creating new record (database row) is very easy. You can either use the Doctrine_Connection::create() or Doctrine_Table::create()
method to do this or just simple use the new operator.
In order to get table object for specified record just call Doctrine_Record::getTable() or Doctrine_Session::getTable().
In order to get table object for specified record just call Doctrine_Record::getTable() or Doctrine_Connection::getTable().
Session state gives you information about how active session currently is. You can get the current state
by calling Doctrine_Session::getState().
Connection state gives you information about how active connection currently is. You can get the current state
by calling Doctrine_Connection::getState().
You can add custom finder methods to your custom table object. These finder methods may use fast
Doctrine_Table finder methods or DQL API (Doctrine_Session::query()).
Doctrine_Table finder methods or DQL API (Doctrine_Connection::query()).
Doctrine_Table provides basic finder methods. These finder methods are very fast and should be used if you only need to fetch
data from one database table. If you need queries that use several components (database tables) use Doctrine_Session::query().
data from one database table. If you need queries that use several components (database tables) use Doctrine_Connection::query().
......@@ -14,8 +14,8 @@ Doctrine_Find_Exception thrown when user tries to find a Doctrine
Doctrine_Naming_Exception thrown when user defined Doctrine_Table is badly named
Doctrine_Session_Exception thrown when user tries to get the current
session and there are no open sessions
Doctrine_Connection_Exception thrown when user tries to get the current
connection and there are no open connections
Doctrine_Table_Exception thrown when user tries to initialize a new instance of Doctrine_Table,
while there already exists an instance of that factory
......
Doctrine has a three-level configuration structure. You can set configuration attributes in global, session and table level.
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.
......@@ -6,11 +6,11 @@ the lazy fetching strategy will be used whenever the records of 'example' table
<br \><br \>
<li> Global level
<ul>
The attributes set in global level will affect every session and every table in each session.
The attributes set in global level will affect every connection and every table in each connection.
</ul>
<li> Session level
<li> Connection level
<ul>
The attributes set in session level will take effect on each table in that session.
The attributes set in connection level will take effect on each table in that connection.
</ul>
<li> Table level
<ul>
......
You can update the related records by calling save for each related object / collection individually or by calling
save on the object that owns the other objects. You can also call Doctrine_Session::flush which saves all pending objects.
save on the object that owns the other objects. You can also call Doctrine_Connection::flush which saves all pending objects.
Doctrine_Manager is the base component of Doctrine ORM framework. Doctrine_Manager is a colletion of Doctrine_Sessions. All the new sessions are being
opened by Doctrine_Manager::openSession().
Doctrine_Manager is the base component of Doctrine ORM framework. Doctrine_Manager is a colletion of Doctrine_Connections. All the new connections are being
opened by Doctrine_Manager::openConnection().
Doctrine_Session is a wrapper for database connection. It creates Doctrine_Tables and keeps track of all the created tables.
Doctrine_Session provides things that are missing from PDO like sequence support and limit/offset emulation.
Doctrine_Connection is a wrapper for database connection. It creates Doctrine_Tables and keeps track of all the created tables.
Doctrine_Connection provides things that are missing from PDO like sequence support and limit/offset emulation.
......@@ -7,7 +7,7 @@ GoF [Gang Of Four] design patterns used:
<dd>For leveled configuration
<li \><a href="http://www.dofactory.com/Patterns/PatternFactory.aspx">Factory</a><br \>
<dd>For session driver loading and many other things
<dd>For connection driver loading and many other things
<li \><a href="http://www.dofactory.com/Patterns/PatternObserver.aspx">Observer</a><br \>
<dd>For event listening
......@@ -16,10 +16,10 @@ GoF [Gang Of Four] design patterns used:
<dd>For efficient usage of validators
<li \><a href="http://www.dofactory.com/Patterns/PatternFlyweight.aspx">Iterator</a><br \>
<dd>For iterating through components [Tables, Sessions, Records etc.]
<dd>For iterating through components [Tables, Connections, Records etc.]
<li \><a href="http://www.dofactory.com/Patterns/PatternState.aspx">State</a><br \>
<dd>For state-wise sessions
<dd>For state-wise connections
<li \><a href="http://www.dofactory.com/Patterns/PatternStrategy.aspx">Strategy</a><br \>
<dd>For algorithm strategies
......
......@@ -5,7 +5,7 @@ For collection elements
Doctrine knows how to fetch collections efficiently using a subselect.
<br \><br \>
<li \><b class="title">Executing SQL statements later, when needed</b><br \>
The session never issues an INSERT or UPDATE until it is actually needed. So if an exception occurs and you need to abort the transaction, some statements will never actually be issued. Furthermore, this keeps lock times in the database as short as possible (from the late UPDATE to the transaction end).
The connection never issues an INSERT or UPDATE until it is actually needed. So if an exception occurs and you need to abort the transaction, some statements will never actually be issued. Furthermore, this keeps lock times in the database as short as possible (from the late UPDATE to the transaction end).
<br \><br \>
<li \><b class="title">Join fetching</b><br \>
Doctrine knows how to fetch complex object graphs using joins and subselects
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment