Commit 14781f1d authored by zYne's avatar zYne

RawSql docs + codes updated

parent f1df2699
......@@ -7,7 +7,7 @@ $query->parseQuery("SELECT {entity.*}, {phonenumber.*}
ON phonenumber.entity_id = entity.id");
$query->addComponent("entity", "Entity");
$query->addComponent("phonenumber", "Phonenumber");
$query->addComponent("phonenumber", "Entity.Phonenumber");
$entities = $query->execute();
?>
The following example represents a bit harder case where we select all entities and their associated phonenumbers using a left join. Again we
wrap all the columns in curly brackets but we also specify what tables associate to which components.
<br \> <br \>
First we specify that table entity maps to record class 'Entity'
<br \><br \>
Then we specify that table phonenumber maps to Entity.Phonenumber (meaning phonenumber associated with an entity)
In Doctrine you may express your queries in the native SQL dialect of your database.
This is useful if you want to use the full power of your database vendor's features (like query hints or the CONNECT keyword in Oracle).
<br \><br \>
It should be noted that not all the sql is portable. So when you make database portable applications you might want to use the DQL API instead.
The rawSql component works in much same way as Zend_Db_Select. You may use method overloading like $q->from()->where() or just use
$q->parseQuery(). There are some differences though:
<br \><br \>
1. In Doctrine_RawSql component you need to specify all the mapped table columns in curly brackets {} this is used for smart column aliasing.
<br \><br \>
2. When joining multiple tables you need to specify the component paths with addComponent() method
<br \><br \>
The following example represents a very simple case where no addComponent() calls are needed.
Here we select all entities from table entity with all the columns loaded in the records.
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