mardi 13 juin 2017

MySQL query statement to PHP statement

I have a configurable MySQL filter (where statement) to fine-tune an export of IP addresses from a database with over 2 million records which are blacklisted.

The where statement can be configured in a settings file. Currently it is configured to append WHERE count > 0 AND count <= 4. Further in the code I need this statement, but then as a PHP statement: if($var > 0 && $var <= 4). I prefer not to create another settings variable containing the PHP statement, which could be executed with an eval(). Why not? eval==evil. Although it is an internal application, I'd like to avoid it if possible.

tl;dr;

Any hints, guides or info how I could create an equal PHP statement from a simple MySQL WHERE statement while avoiding eval. I could not find any satisfying, nor could I come up with a good approach to try - sorry. So any tips in the right direction would be appreciated.

Aucun commentaire:

Enregistrer un commentaire