diff options
author | Indieteq <admin@indieteq.com> | 2012-11-14 23:28:21 +0100 |
---|---|---|
committer | Indieteq <admin@indieteq.com> | 2012-11-14 23:28:21 +0100 |
commit | 2fedec82f555bbfc9b020f88de821675f103131e (patch) | |
tree | dcfdd4f8dd1375fd364f9a1be3ee22f5f1c70b57 | |
parent | 33260959a1a666a636c0825a7bfba54cd174fc99 (diff) | |
download | php-mysql-pdo-database-class-2fedec82f555bbfc9b020f88de821675f103131e.zip php-mysql-pdo-database-class-2fedec82f555bbfc9b020f88de821675f103131e.tar.gz php-mysql-pdo-database-class-2fedec82f555bbfc9b020f88de821675f103131e.tar.bz2 |
Update README.md
-rw-r--r-- | README.md | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -52,7 +52,10 @@ If you want to use these files you''ll have to modify the rights of the logs fol // Fetch whole table $persons = $db->query("SELECT * FROM persons"); ``` -#### Fetching with Bindings: +#### Fetching with Bindings (ANTI-SQL-INJECTION): +Binding parameters is the best way to prevent SQL injection. The class prepares your SQL query and binds the parameters +afterwards. + There are three different ways to bind parameters. ```php <?php @@ -136,7 +139,11 @@ Here an example : ```php <?php // Fetch style as third parameter - $persons_num = $db->query("SELECT * FROM Persons", null, PDO::FETCH_NUM); + $person_num = $db->row("SELECT * FROM Persons WHERE id = :id", array("id"=>"1"), PDO::FETCH_NUM); + + print_r($person_num); + // Array ( [0] => 1 [1] => Johny [2] => Doe [3] => M [4] => 19 ) + ``` More info about the PDO fetchstyle : http://php.net/manual/en/pdostatement.fetch.php @@ -150,7 +157,8 @@ Actually it's just a little ORM class. ## How to use easyCRUD #### 1. First, create a new class. Then require the easyCRUD class. -#### 2. Extend your class and add the following fields to the class. +#### 2. Extend your class to the base class Crud and add the following fields to the class. +#### Example class : ```php <?php require_once("easyCRUD.class.php"); |