1
0
mirror of synced 2025-01-20 23:41:39 +03:00
This commit is contained in:
zYne 2007-09-29 09:20:53 +00:00
parent 4eee98d526
commit e647cdbba5

View File

@ -10,32 +10,36 @@ When compared to using raw SQL, DQL has several benefits:
If the power of DQL isn't enough, you should consider using the rawSql API for object population.
You may already be familiar with the following syntax:
<code type="php">
// DO NOT USE THE FOLLOWING CODE
// (using many sql queries for object population):
// DO NOT USE THE FOLLOWING CODE
// (uses many sql queries for object population)
$users = $conn->getTable('User')->findAll();
foreach($users as $user) {
print $user->name."
";
print $user->name . ' has phonenumbers: ';
foreach($user->Phonenumber as $phonenumber) {
print $phonenumber."
";
print $phonenumber . ' ';
}
}
<code>
// same thing implemented much more efficiently:
However you should not use it. Above is the same behaviour implemented much more efficiently:
<code type="php">
// same thing implemented much more efficiently:
// (using only one sql query for object population)
$users = $conn->query("FROM User.Phonenumber");
$users = $conn->query('FROM User u LEFT JOIN u.Phonenumber p');
foreach($users as $user) {
print $user->name."
";
print $user->name . ' has phonenumbers: ';
foreach($user->Phonenumber as $phonenumber) {
print $phonenumber."
";
print $phonenumber . ' ';
}
}
</code>