From 77036b677a514735271f90701d207f1250dd5e8e Mon Sep 17 00:00:00 2001 From: tigglet Date: Sat, 19 Jan 2008 17:11:22 +0000 Subject: [PATCH] Added Doctrine::HYDRATE_NONE example to "Fetch Only What You Need" subchapter of the "Improving performanc" chapter. --- .../en/improving-performance/fetch-only-what-you-need.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/manual/docs/en/improving-performance/fetch-only-what-you-need.txt b/manual/docs/en/improving-performance/fetch-only-what-you-need.txt index ace6eab1d..6ed0937bf 100644 --- a/manual/docs/en/improving-performance/fetch-only-what-you-need.txt +++ b/manual/docs/en/improving-performance/fetch-only-what-you-need.txt @@ -50,3 +50,11 @@ foreach ($comments as $comment) { echo $comment['author']['first_name'] . ' - ' . $comment['author']['last_name'] . '
'; } **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: + +$total = Doctrine_Query::create() + ->select('SUM(d.amount)') + ->from('Donation d') + ->execute(array(), Doctrine::HYDRATE_NONE); +