1
0
mirror of synced 2024-12-13 06:46:03 +03:00

Added Doctrine::HYDRATE_NONE example to "Fetch Only What You Need" subchapter of the "Improving performanc" chapter.

This commit is contained in:
tigglet 2008-01-19 17:11:22 +00:00
parent 4b95d0504c
commit 77036b677a

View File

@ -50,3 +50,11 @@ foreach ($comments as $comment) {
echo $comment['author']['first_name'] . ' - ' . $comment['author']['last_name'] . '<br />';
}
</code> **Array fetching is the best choice whenever you need data read-only like passing it to the view for display. And from my experience, most of the time when you fetch a large amount of data it's only for display purposes. And these are exactly the cases where you get the best performance payoff when fetching arrays instead of objects.**
Sometimes, you may want the direct output from PDO instead of an object or an array. To do this, set the hydration mode to **Doctrine::HYDRATE_NONE**. Here's an example:
<code type="php">
$total = Doctrine_Query::create()
->select('SUM(d.amount)')
->from('Donation d')
->execute(array(), Doctrine::HYDRATE_NONE);
</code>