Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP CRUD Operations with PHP Creating Records Reading Project Data

Should we use fetchAll(PDO::FETCH_ASSOC)?

Hi Alena Holligan ,

In your "integrating php with databases" tutorial (link below) you used PDO::(FETCH_ASSOC) to filter the results. This filtered the results so that it would return only an Associative Array instead of both an Associative and Indexed Array.

Would you recommend we use it here? If not, what is the reason? Also does PDO::FETCH_ASSOC increase performance?

I modified my return to in the try portion to:

return $db->query('SELECT project_id, title, category FROM projects')->fetchAll(PDO::FETCH_ASSOC);

Should I change it back to the way you have it in this video?

https://teamtreehouse.com/library/integrating-php-with-databases/querying-the-database-with-php/retrieving-the-result-set