A general question, without a specific case in mind - is it usually preferred to use MySQL stored procedures over writing a PHP script that performs the same calculations an
I would say "don't make too much magic with the database". The worst case would be for a new developper on the project to notice that ** an operation ** is done, but he cannot see where in the code it is. So he keeps looking for it. But it's done in the database.
So if you do some "invisible" database operations (I'm thinking about triggers), just write it in some code documentation.
// add a new user
$user = new User("john", "doe");
$user->save();
// The id is computed by the database see MYPROC_ID_COMPUTATION
print $user->getId();
In the other hand, writing functions for the DB is a good idea, and would provide the developer a good abstraction layer.
// Computes an ID for the given user
DB->execute("SELECT COMPUTE_ID(" . $user->getLogin() . ") FROM DUAL");
Of course this is all pseudo-code, but I hope you understand my obscure idea.