PHP fully supports these use cases and everything in between. The same is true for Python and Ruby, but their web development ecosystem gravitates much more towards single solutions (Django, Rails).
Yes, that means many Django or Rails developers have a hard time developing outside the box of their framework. However, on the PHP end you often see a lack of knowledge of the tools available and a strong tendency towards "not invented here".
It all comes down to making informed choices. The language doesn't make that much of a difference. Every language allows you to optimize db-access to the point of writing raw SQL queries, and no framework can stop you from leveraging the raw power of the language.