forked from wickyaswal/php-my-sql-pdo-database-class
-
Notifications
You must be signed in to change notification settings - Fork 2
/
easyCrud.php
48 lines (38 loc) · 1000 Bytes
/
easyCrud.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
require 'vendor/autoload.php';
// Use the person class file
use Indieteq\PDO\easyCrud\Person;
// Instantiate the person class
$person = new Person();
// Create new person
$person->Firstname = "Kona";
$person->Age = "20";
$person->Sex = "F";
$creation = $person->Create();
// Update Person Info
$person->id = "4";
$person->Age = "32";
$saved = $person->Save();
// Find person
$person->id = "4";
$person->Find();
d($person->Firstname, "Person->Firstname");
d($person->Age, "Person->Age");
// Delete person
$person->id = "17";
$delete = $person->Delete();
// Get all persons
$persons = $person->all();
// Aggregates methods
d($person->max('age'), "Max person age");
d($person->min('age'), "Min person age");
d($person->sum('age'), "Sum persons age");
d($person->avg('age'), "Average persons age");
d($person->count('id'), "Count persons");
function d($v, $t = "")
{
echo '<pre>';
echo '<h1>' . $t . '</h1>';
var_dump($v);
echo '</pre>';
}