|
1 | | -frosted-mysql-library |
2 | | -===================== |
| 1 | +Frosted MySQL Library for PHP |
| 2 | +============================= |
3 | 3 |
|
4 | | -The Frosted MySQL Library for PHP is an extension to the default mysql and mysqli functions. Withit you can easily create complex queries and get big advantages on development. Just take a look to the examples. |
| 4 | +The`Frosted MySQL Library` is an extension to the default`mysql` and`mysqli` functions of php. |
| 5 | +With it you can easily create complex queries and get big advantages while development. |
| 6 | +Beginners or infrequent developers will get an easy entry to mysql and pro's can do it's work much faster and with more possibilities. |
| 7 | +Just take a look to the examples or read the little documentation below. |
| 8 | + |
| 9 | +As of the official mysql documentation, the`Frosted MySQL Library` can create**100%** of all`INSERT`,`UPDATE`,`DELETE`,`REPLACE`,`TRUNCATE` queries and nearly every`SELECT` query you want |
| 10 | +(the only exception are the sql parameters and the file output in the`SELECT` query). |
| 11 | + |
| 12 | +All classes in the library has fully support for code-completion in IDEs like`PHPStorm` or`Aptana` and are documented with`PHPDoc`. |
| 13 | + |
| 14 | +##Features## |
| 15 | +* support`mysql` and`mysqli` |
| 16 | +* optional persistent connections |
| 17 | +*`read-only` and`write` permissions |
| 18 | +* in-query replacements |
| 19 | +* automatically escaping all values |
| 20 | +* create queries in`oop` way |
| 21 | +* detailed error messages |
| 22 | +* receive results in many formats |
| 23 | +* dynamically create`collections` of results |
| 24 | +* formatted query output if wished |
| 25 | +* dynamic parameters to create queries in many ways |
| 26 | +* many alias methods to write the code as you think |
| 27 | +* fully documented with`PHPDoc` |
| 28 | +* support for auto complete in IDEs like`PHPStorm` or`Aptana` |
| 29 | +* easy to configure, easy to use |
| 30 | +*_and much more ..._ |
| 31 | + |
| 32 | +###Installation### |
| 33 | +To use the`Frosted MySQL Library` just include the`packed` file, or every single file in the`classes/` folder (the`mysql.config.php` is optional) in your scripts. |
| 34 | +With the`packed` version you receive the full library within one file and is the best solution for the most. |
| 35 | +If you doesn't use all features you can include all needed files by your own. |
| 36 | + |
| 37 | +```PHP |
| 38 | +require_once("packed/mysql.class.packed.php"); |
| 39 | +include("packed/mysql.config.php") |
| 40 | +``` |
| 41 | + |
| 42 | +###Config & Examples### |
| 43 | +After including the`Frosted MySQL Library` you just have to configure the mysql server settings and start using it. |
| 44 | +Take a look to the`examples/02_config.php`, to see which settings are available and how to do this in different ways. |
| 45 | +A manual way to configure the library is seen below. |
| 46 | +In the`examples/` folder you will find more different examples to get you into the code. |
| 47 | + |
| 48 | +```PHP |
| 49 | +$sql = new mysqlClass(); |
| 50 | +$sql->setHostname("localhost"); |
| 51 | +$sql->setUsername("root"); |
| 52 | +$sql->setPassword("Pass1234"); |
| 53 | +$sql->setDatabase("frosted"); |
| 54 | + |
| 55 | +$sql->connect(); |
| 56 | + |
| 57 | +// start using Frosted MySQL Library ... |
| 58 | +``` |
| 59 | + |
| 60 | +###Queries### |
| 61 | +As the whole library, creating a query is very simple and straight-forward. |
| 62 | +Just write the code as you would, when writing an mysql query. |
| 63 | +If you use an IDE like PHPStorm or Aptana you will take advantage of the automatically code-completion which can show you all possible options. |
| 64 | + |
| 65 | +```PHP |
| 66 | +$result = $sql->select("id") |
| 67 | + ->from("users") |
| 68 | + ->where("login = ?", "frosted@eisbehr.de") |
| 69 | + ->limit(1) |
| 70 | + ->run() |
| 71 | + ->fetch(); |
| 72 | +``` |
| 73 | + |
| 74 | +This is equal to the mysql query: |
| 75 | + |
| 76 | +```MYSQL |
| 77 | +SELECT idFROM usersWHERE login='frosted@eisbehr.de'LIMIT1 |
| 78 | +``` |
| 79 | + |
| 80 | +###Sub-Queries### |
| 81 | + |
| 82 | +###Alternative Calls### |
| 83 | +To support your coding style and to use the classes in many, many different ways, the most query functions have dynamical parameters. |
| 84 | +The default parameters are more an hint as an strict requirement. An example with select columns: |
| 85 | + |
| 86 | +```PHP |
| 87 | +// this |
| 88 | +$sql->select("id", "name", "email"); |
| 89 | + |
| 90 | +// is the same as |
| 91 | +$sql->select(array("id", "name", "email")); |
| 92 | + |
| 93 | +// is the same as |
| 94 | +$sql->select("id", array("name", "email")); |
| 95 | + |
| 96 | +// is the same as |
| 97 | +$sql->select()->columns("id", "name", "email"); |
| 98 | + |
| 99 | +// is the same as |
| 100 | +$sql->select()->columns(array("id", "name", "email")); |
| 101 | + |
| 102 | +// is the same as |
| 103 | +sql->select()->columns(array("id"), "name", "email"); |
| 104 | + |
| 105 | +// is the same as |
| 106 | +$sql->select("id")->column("name")->column("email"); |
| 107 | + |
| 108 | +// is the same as |
| 109 | +$sql->select(array("id" => "id", "name" => "name", "email" => "email"); |
| 110 | + |
| 111 | +// and so on ... |
| 112 | +``` |
| 113 | + |
| 114 | +###Results### |
| 115 | + |
| 116 | +###Collection### |
| 117 | + |
| 118 | +###Replacement### |