-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact_tests.php
53 lines (46 loc) · 1.28 KB
/
contact_tests.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 => Alan Turing,
// email => [email protected]
echo '<br/><br/>';
echo $contact->getData('name');
// Should print:
// Alan Turing
$contact->setData('name', 'Donald Knuth')->save(); // Should run an UPDATE query
echo '<br/><br/>';
print_r($contact->load(1)->getData());
// Should print
// id => 1,
// name => Donald Knuth,
// email => [email protected]
$contact->setData(array(
"id" => 1,
"name" => "Grace Hopper",
"email" => "[email protected]"
))->save();
echo '<br/><br/>';
print_r($contact->load(1)->getData());
// Should print
// id => 1,
// name => Grace Hopper,
// email => [email protected]
$newContact = new Contact();
$newContact->setData(array(
"name" => "Alonzo Church",
"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 => Alonzo Church,
// email => [email protected]
$newContact->delete(); // Should delete Mr. Church from the database