forked from Zachdidit/applicant_project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact_test.php
53 lines (46 loc) · 1.27 KB
/
contact_test.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
49
50
51
52
53
<?PHP
require_once("AbstractModel.php");
require_once("Contact.php");
ini_set("display_errors", true);
$contact = new Contact();
$contact->load(1);
print_r($contact->getData());
// Should print:
// id => 1,
// name => John Doe
// email => [email protected]
echo '<br/><br/>';
echo $contact->getData('name');
//Should print:
// John Doe
$contact->setData('name', 'John Walker')->save(); //Should run an UPDATE query
echo '<br/><br/>';
print_r($contact->load(1)->getData());
//Should print
// id => 1,
// name => John Walker
// email => [email protected]
$contact->setData(array(
"id" => 1,
"name" => "John Doe the 2nd",
"email" => "[email protected]"
))->save();
echo '<br/><br/>';
print_r($contact->load(1)->getData());
//Should print
// id => 1,
// name => John Doe the 2nd
// email => [email protected]
$newContact = new Contact();
$newContact->setData(array(
"name" => "Gilbert Barber",
"email" => "[email protected]"
));
$newContact->save(); //Should run an INSERT query as there is no predefined id
echo '<br/><br/>';
print_r($newContact->getData());
//Should print
// id => ? some auto increment number,
// name => Gilbert Barber
// email => [email protected]
$newContact->delete(); //Should delete him Gilbert Barber from the database