PHP 7 has gotten rid of mysql_query()
because it's problematic in a variety of ways! The API does not encourage good practices, the official line is that it's unmaintained, and NO PREPARED STATEMENTS!?! It essentially is the biggest problem in PHP that encourages bad practices leading to sql injection, and that's a major big bad situation.
However, I do work with legacy codebases, so I have to deal with the same situation as you in some cases. If you have a small codebase, just update your db connection method. If you have a large codebase, here is what I recommend:
- Rollback your php version for this codebase to php 5.6, it will be supported for a bit more of 2016.
- Take your time to update to PDO (you can create a
wrapper around PDO to make it less verbose and still allow prepared
queries).
- Ignore mysqli. If it takes you 5 minutes to upgrade from mysql_*, you are probably doing it wrong, and leaving yourself open to sql-injection. Just go for PDO and start using prepared queries so you can sleep at night.
- If you still want to use php 7 in more modern projects, spin up a container instance with the older php 5.6 legacy codebases on it.