sergiodanilojr /
crud
| 1 | <?php |
||
| 2 | |||
| 3 | require __DIR__ . "/../vendor/autoload.php"; |
||
| 4 | |||
| 5 | use ElePHPant\CRUD; |
||
| 6 | |||
| 7 | /* QuickStart with CRUD class :: Call the class and set table from database that you'll use */ |
||
| 8 | $crud = (new CRUD())::setTable("users"); |
||
| 9 | |||
| 10 | /* Create */ |
||
| 11 | $arrayWithData = array(...); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 12 | $create = $crud->create($arrayWithData); |
||
| 13 | |||
| 14 | /* Reading Data :: For Default the read Method utilize the \stdClass like FETCH_CLASS, but ou can utilize other Concrete class for thar */ |
||
| 15 | $read = $crud->read(stdClass::class, true); |
||
| 16 | |||
| 17 | /* Update */ |
||
| 18 | $update = $crud->update($arrayWithData, "gender = 'male'"); |
||
| 19 | |||
| 20 | /* Delete */ |
||
| 21 | $delete = $crud->delete("id = :id", "id=1"); |
||
| 22 | |||
| 23 | /* Setting Params with CRUD Class */ |
||
| 24 | $params = "gender = :gender"; |
||
| 25 | $crud->setParams($params); |
||
| 26 | |||
| 27 | /* DEBUGGING :: For you identify your Query*/ |
||
| 28 | var_dump($crud->getQuery()); |
||
| 29 | |||
| 30 | /* PDOException */ |
||
| 31 | if (!$crud->create($arrayWithData)) { |
||
| 32 | var_dump($crud->getFail()); |
||
| 33 | } |
||
| 34 |