SafeMySQL
=========
SafeMySQL is a PHP class for safe and convenient handling of MySQL queries.
- Safe because < b > every</ b > dynamic query part goes into the query via < b > placeholder</ b >
- Convenient because it makes application code short and meaningful, without useless repetitions, making it ''extra'' < abbr title = "Don't Repeat Yourself" > DRY</ abbr >
This class is distinguished by three main features
- Unlike standard libraries, it is using **type-hinted placeholders** , for the **everything** that may be put into the query
- Unlike standard libraries, it requires no repetitive binding, fetching and such,
thanks to set of helper methods to get the desired result right out of the query
- Unlike standard libraries, it can parse placeholders not in the whole query only, but in the arbitary query part,
thanks to the indispensabe **parse()** method, making complex queries as easy and safe as regular ones.
Yet, it is very easy to use. You need to learn only a few things:
1. You have to **always** pass whatever dynamical data into the query via *placeholder*
2. Each placeholder have to be marked with data type. At the moment there are six types:
* ?s ("string") - strings (also ```DATE```, ```FLOAT``` and ```DECIMAL```)
* ?i ("integer") - the name says it all
* ?n ("name") - identifiers (table and field names)
* ?a ("array") - complex placeholder for ```IN()``` operator (substituted with string of 'a','b','c' format, without parentesis)
* ?u ("update") - complex placeholder for ```SET``` operator (substituted with string of `field` ='value',`field`='value' format)
* ?p ("parsed") - special type placeholder, for inserting already parsed statements without any processing, to avoid double parsing.
3. To get data right out of the query there are helper methods for the most used:
* query($query,$param1,$param2, ...) - returns mysqli resource.
* getOne($query,$param1,$param2, ...) - returns scalar value
* getRow($query,$param1,$param2, ...) - returns 1-dimensional array, a row
* getCol($query,$param1,$param2, ...) - returns 1-dimensional array, a column
* getAll($query,$param1,$param2, ...) - returns 2-dimensional array, an array of rows
* getInd($key,$query,$par1,$par2, ...) - returns an indexed 2-dimensional array, an array of rows
* getIndCol($key,$query,$par1,$par2, ...) - returns 1-dimensional array, an indexed column, consists of key => value pairs
4. For the whatever complex case always use the **parse()** method. And insert