MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mconnection.class
Ir para a documentação deste ficheiro.
1
<?php
2
3
class
MConnection
4
{
5
var
$db
;
// database object
6
var
$id
;
// the connection identifier
7
var
$traceback
= array();
// a list of connection errors
8
var
$affectedrows
;
9
14
var
$_miolo
;
// MIOLO object
15
16
function
__construct
(
$db
)
17
{
18
$this->db =
$db
;
19
$this->_miolo = $this->db->_miolo;
20
$this->_miolo->Uses(
'database/'
.
$db
->system .
'/mquery.class'
);
21
}
22
23
// Virtual methods - to be implemented by the specific drivers
24
25
public
function
_connect
($dbhost, $LoginDB, $LoginUID, $LoginPWD, $persistent =
true
, $port=
''
)
26
{
27
}
28
29
public
function
_close
()
30
{
31
}
32
33
public
function
_error
()
34
{
35
}
36
37
public
function
_execute
($sql)
38
{
39
}
40
41
public
function
_createquery
()
42
{
43
}
44
45
public
function
_createproc
()
46
{
47
}
48
49
public
function
_chartotimestamp
($timestamp)
50
{
51
}
52
53
public
function
_chartodate
($date)
54
{
55
}
56
57
public
function
_timestamptochar
($timestamp)
58
{
59
}
60
61
public
function
_datetochar
($date)
62
{
63
}
64
65
// opens a connection to the specified data source
66
function
Open
($dbhost, $LoginDB, $LoginUID, $LoginPWD, $persistent =
true
, $parameters = NULL, $port=NULL)
67
{
68
if
($this->
id
)
69
{
70
$this->
Close
();
71
}
72
$this->
_connect
($dbhost, $LoginDB, $LoginUID, $LoginPWD, $persistent, $parameters, $port);
73
if
(!$this->
id
)
74
{
75
$this->traceback[] =
"Unable to estabilish DataBase Conection to host: $dbhost, DB: $LoginDB"
;
76
}
77
return
$this->id
;
78
}
79
80
function
Close
()
81
{
82
if
($this->
id
)
83
{
84
$this->
_close
($this->
id
);
85
$this->
id
= 0;
86
}
87
}
88
89
function
GetError
()
90
{
91
if
(!$this->
id
)
92
{
93
$err = _M(
"No valid Database connection estabilished."
);
94
}
95
elseif ($this->traceback)
96
{
97
$err .=
"<br>"
. implode(
"<br>"
, $this->traceback);
98
}
99
return
$err;
100
}
101
102
function
GetErrors
()
103
{
104
return
$this->traceback
;
105
}
106
107
function
GetErrorCount
()
108
{
109
return
count($this->traceback);
110
}
111
112
function
CheckError
()
113
{
114
if
(empty($this->traceback))
115
{
116
return
;
117
}
118
$n = count($this->traceback);
119
if
($n > 0)
120
{
121
$msg =
""
;
122
for
($i = 0; $i < $n; $i++)
123
{
124
$msg .= $this->traceback[$i] .
"<br>"
;
125
}
126
}
127
if
($msg !=
''
)
128
{
129
throw
new
EDatabaseException
($this->db->conf, $msg);
130
}
131
}
132
133
function
Execute
($sql)
134
{
135
$this->_miolo->LogSQL($sql,
false
, $this->db->conf);
136
137
if
(!($success = $this->
_execute
($sql)))
138
{
139
throw
new
EDatabaseExecException
($this->
GetError
());
140
}
141
142
return
$success;
143
}
144
145
function
Parse
($sql)
146
{
147
$this->_miolo->LogSQL( _M(
'Parse: '
) . $sql->command,
false
, $this->db->conf);
148
$sql->stmt = $this->_parse($sql->command);
149
}
150
151
function
Bind
($sql)
152
{
153
if
($binds = $sql->parameters)
154
{
155
foreach
($binds as $ph => $pv)
156
{
157
$this->_bind($sql->stmt, $ph, $pv);
158
}
159
}
160
}
161
162
function
getQuery
($sql, $maxrows =
null
, $offset =
null
)
163
{
164
$this->_miolo->Assert($this->
id
, $this->
GetErrors
());
165
try
166
{
167
$query = $this->
_createquery
();
168
$query->SetConnection($this);
169
$query->SetSQL($sql);
170
if
($sql->bind)
171
{
172
if
(!$sql->stmt)
173
{
174
$this->
Parse
($sql);
175
}
176
177
$this->
Bind
($sql);
178
}
179
180
$query->Open($maxrows, $offset, $sql->stmt);
181
}
182
catch
( Exception $e )
183
{
184
throw
$e;
185
}
186
187
return
$query;
188
}
189
190
function
getQueryCommand
($sqlCommand, $maxrows =
null
, $offset =
null
)
191
{
192
$this->_miolo->Assert($this->
id
, $this->
GetErrors
());
193
$query = $this->
_createquery
();
194
$query->SetConnection($this);
195
$query->SetSQLCommand($sqlCommand);
196
$query->Open($maxrows, $offset);
197
return
$query;
198
}
199
200
function
ExecProc
($sql, $aParams =
null
)
201
{
202
$this->_miolo->Assert($this->
id
, $this->
GetErrors
());
203
$q = $this->
_createproc
();
204
$q->conn = &$this;
205
if
($sql !=
""
)
206
{
207
$q->ExecProc($sql, $aParams);
208
}
209
return
($q->result ? $q->result : (!$q->error));
210
}
211
}
212
?>
EDatabaseException
Definição
mexception.class:43
EDatabaseExecException
Definição
mexception.class:53
MConnection
Definição
mconnection.class:4
MConnection\_timestamptochar
_timestamptochar($timestamp)
Definição
mconnection.class:57
MConnection\_execute
_execute($sql)
Definição
mconnection.class:37
MConnection\$db
$db
Definição
mconnection.class:5
MConnection\_createproc
_createproc()
Definição
mconnection.class:45
MConnection\Close
Close()
Definição
mconnection.class:80
MConnection\_datetochar
_datetochar($date)
Definição
mconnection.class:61
MConnection\Bind
Bind($sql)
Definição
mconnection.class:151
MConnection\$_miolo
$_miolo
Definição
mconnection.class:14
MConnection\_close
_close()
Definição
mconnection.class:29
MConnection\Execute
Execute($sql)
Definição
mconnection.class:133
MConnection\Open
Open($dbhost, $LoginDB, $LoginUID, $LoginPWD, $persistent=true, $parameters=NULL, $port=NULL)
Definição
mconnection.class:66
MConnection\ExecProc
ExecProc($sql, $aParams=null)
Definição
mconnection.class:200
MConnection\getQuery
getQuery($sql, $maxrows=null, $offset=null)
Definição
mconnection.class:162
MConnection\$affectedrows
$affectedrows
Definição
mconnection.class:8
MConnection\$traceback
$traceback
Definição
mconnection.class:7
MConnection\GetErrors
GetErrors()
Definição
mconnection.class:102
MConnection\getQueryCommand
getQueryCommand($sqlCommand, $maxrows=null, $offset=null)
Definição
mconnection.class:190
MConnection\__construct
__construct($db)
Definição
mconnection.class:16
MConnection\_error
_error()
Definição
mconnection.class:33
MConnection\CheckError
CheckError()
Definição
mconnection.class:112
MConnection\Parse
Parse($sql)
Definição
mconnection.class:145
MConnection\GetErrorCount
GetErrorCount()
Definição
mconnection.class:107
MConnection\_connect
_connect($dbhost, $LoginDB, $LoginUID, $LoginPWD, $persistent=true, $port='')
Definição
mconnection.class:25
MConnection\_chartodate
_chartodate($date)
Definição
mconnection.class:53
MConnection\GetError
GetError()
Definição
mconnection.class:89
MConnection\$id
$id
Definição
mconnection.class:6
MConnection\_createquery
_createquery()
Definição
mconnection.class:41
MConnection\_chartotimestamp
_chartotimestamp($timestamp)
Definição
mconnection.class:49
classes
database
mconnection.class
Gerado por
1.10.0