Context: 

* We have a PHP/MySQL application.
* Some portions of the calculations are done in SQL directly. eg: All users created in the last 24 hours would be returned via an SQL query ( NOW() – 1 day)

There's a debate going on between a fellow developer and me where I'm having the opinion that we should:

A. Keep all calculations / code / logic in PHP and treat MySQL as a 'dumb' repository of information

His opinion:

B. Do a mix and match depending on whats easier / faster. <http://www.onextrapixel.com/2010/06/23/mysql-has-functions-part-5-php-vs-mysql-performance/>

I'm looking at maintainability point-of-view. He's looking at speed (which as the article points out, some operations are faster in MySQL).

---

@bob-the-destroyer
@tekretic
@OMG Ponies 
@mu is too short 
@Tudor Constantin
@tandu 
@Harley

I agree (and quite obviously) efficient WHERE clauses belong in the SQL level. However, what about examples like:

1. Calculating a 24 period using NOW() - 1 day in SQL to select all users created in last 24 hours?
2. Return capitalized first name and last name of all users?
3. Concatenating a string?
4. (thoughts, folks?)

Clear examples belonging in the SQL domain:

1. specific WHERE selections
2. Nested SQL statements
3. Ordering / Sorting
4. Selecting DISTINCT items
5. Counting rows / items