-
Notifications
You must be signed in to change notification settings - Fork 0
/
DatabaseConfig.php
103 lines (84 loc) · 2.09 KB
/
DatabaseConfig.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
namespace dc\yukon;
require_once('config.php');
// Data structure for the options parameter when preparing SQL queries.
interface iDatabaseConfig
{
function get_error(); // Error handling object.
function get_scrollable(); // Return cursor scrollable.
function get_sendstream(); // Return sendstream.
function get_timeout(); // Return timeout.
function set_error($value); // Set exception catch toggle.
function set_scrollable($value); // Set cursor scrollable.
function set_sendstream($value); // Set sendstream.
function set_timeout($value); // Set timeout.
}
class DatabaseConfig implements iDatabaseConfig
{
private
$error = NULL, // Exception catching flag.
$scrollable = NULL, // Cursor type.
$sendstream = NULL, // Send all stream data at execution (TRUE), or to send stream data in chunks (FALSE)
$timeout = NULL; // Query timeout in seconds.
public function __construct(Error $error = NULL)
{
// Populate defaults.
$this->error = $this->construct_error($error);
$this->scrollable = DEFAULTS::SCROLLABLE;
$this->sendstream = DEFAULTS::SENDSTREAM;
$this->timeout = DEFAULTS::TIMEOUT;
}
// Accessors
public function get_error()
{
return $this->error;
}
public function get_scrollable()
{
return $this->scrollable;
}
public function get_sendstream()
{
return $this->timeout;
}
public function get_timeout()
{
return $this->timeout;
}
// Mutators
public function set_error($value)
{
$this->error = $value;
}
public function set_scrollable($value)
{
$this->scrollable = $value;
}
public function set_sendstream($value)
{
$this->sendstream = $value;
}
public function set_timeout($value)
{
$this->timeout = $value;
}
// Constructors
private function construct_error(Error $value = NULL)
{
$result = NULL; // Final connection result.
// Verify argument is an object.
$is_object = is_object($value);
if($is_object)
{
$result = $value;
}
else
{
$result = new Error();
}
// Populate member with result.
$this->error = $result;
return $result;
}
}
?>