File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,10 @@ If you want to use these files you''ll have to modify the rights of the logs fol
52
52
// Fetch whole table
53
53
$persons = $db->query("SELECT * FROM persons");
54
54
```
55
- #### Fetching with Bindings:
55
+ #### Fetching with Bindings (ANTI-SQL-INJECTION):
56
+ Binding parameters is the best way to prevent SQL injection. The class prepares your SQL query and binds the parameters
57
+ afterwards.
58
+
56
59
There are three different ways to bind parameters.
57
60
``` php
58
61
<?php
@@ -136,7 +139,11 @@ Here an example :
136
139
``` php
137
140
<?php
138
141
// Fetch style as third parameter
139
- $persons_num = $db->query("SELECT * FROM Persons", null, PDO::FETCH_NUM);
142
+ $person_num = $db->row("SELECT * FROM Persons WHERE id = :id", array("id"=>"1"), PDO::FETCH_NUM);
143
+
144
+ print_r($person_num);
145
+ // Array ( [0] => 1 [1] => Johny [2] => Doe [3] => M [4] => 19 )
146
+
140
147
```
141
148
More info about the PDO fetchstyle : http://php.net/manual/en/pdostatement.fetch.php
142
149
@@ -150,7 +157,8 @@ Actually it's just a little ORM class.
150
157
151
158
## How to use easyCRUD
152
159
#### 1. First, create a new class. Then require the easyCRUD class.
153
- #### 2. Extend your class and add the following fields to the class.
160
+ #### 2. Extend your class to the base class Crud and add the following fields to the class.
161
+ #### Example class :
154
162
``` php
155
163
<?php
156
164
require_once("easyCRUD.class.php");
You can’t perform that action at this time.
0 commit comments