MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mquery.class
Ir para a documentação deste ficheiro.
1
<?php
6
class
PostgresQuery
extends
MQuery
7
{
11
var
$id_result
;
12
20
function
__construct
()
21
{
22
parent::__construct();
23
}
24
32
function
_query
()
33
{
34
$this->
fetched
=
false
;
35
$this->
sql
= $this->
maxrows
? $this->
sql
.
" LIMIT $this->maxrows"
:
$this->sql
;
36
$this->
sql
= $this->
offset
? $this->
sql
.
" OFFSET $this->offset"
:
$this->sql
;
37
38
$this->
id_result
=
pg_query
($this->
conn
->id,
$this
->sql);
39
$this->
conn
->throwError($this->
id_result
);
40
41
//Adicionado para tratar erros onde é feito um insert dentro de uma query. Exemplo, quando
42
//se quer retorno de uma chave no insert #50336
43
if
( strlen(
pg_last_error
($this->
conn
->id)) > 0 )
44
{
45
throw
new
MDatabaseException
(
pg_last_error
($this->
conn
->id));
46
}
47
48
$this->error = $this->
_error
();
49
50
if
(!$this->error)
51
{
52
if
($this->rowCount =
pg_num_rows
($this->
id_result
))
53
{
54
for
(
$n
= 0;
$n
<
$this->rowCount
; $this->
result
[
$n
] =
pg_fetch_array
($this->
id_result
,
$n
,
PGSQL_NUM
),
$n
++);
55
$this->
fetched
=
true
;
56
}
57
58
$this->
colCount
=
pg_num_fields
($this->
id_result
);
59
}
60
61
return
(!$this->error);
62
}
63
67
public
function
_error
()
68
{
69
return
$this->
conn
->getErrorField($this->
id_result
);
70
}
71
79
function
_close
()
80
{
81
if
($this->
id_result
)
82
pg_free_result
($this->
id_result
);
83
}
84
92
function
_setmetadata
()
93
{
94
$numCols =
$this->colCount
;
95
$this->
metadata
=
array
();
96
97
for
(
$i
= 0;
$i
< $numCols;
$i
++)
98
{
99
$name =
strtoupper
(@
pg_field_name
($this->
id_result
,
$i
));
100
$this->
metadata
[
'fieldname'
][
$i
] = $name;
101
$this->
metadata
[
'fieldtype'
][$name] = $this->
_getmetatype
(@
pg_field_type
($this->
id_result
,
$i
));
102
$this->
metadata
[
'fieldlength'
][$name] = @
pg_field_size
($this->
id_result
,
$i
);
103
$this->
metadata
[
'fieldpos'
][$name] =
$i
;
104
}
105
}
106
116
function
_getmetatype
(
$type
)
117
{
118
$type
=
strtoupper
(
$type
);
119
$rType
=
'N'
;
120
121
if
(
$type
==
"VARCHAR"
)
122
{
123
$rType
=
'C'
;
124
}
125
elseif
(
$type
==
"CHAR"
)
126
{
127
$rType
=
'C'
;
128
}
129
elseif
(
$type
==
"NUMBER"
)
130
{
131
$rType
=
'N'
;
132
}
133
elseif
(
$type
==
"DATE"
)
134
{
135
$rType
=
'T'
;
136
}
137
138
return
$rType
;
139
}
140
}
141
?>
MDataSet\$rowCount
$rowCount
Definição
mdataset.class:21
MDataSet\$colCount
$colCount
Definição
mdataset.class:26
MDataSet\$type
$type
Definição
mdataset.class:46
MDataSet\$row
$row
Definição
mdataset.class:16
MDatabaseException
Definição
mdatabaseexception.class:32
MQuery
Definição
mquery.class:3
MQuery\$sql
$sql
Definição
mquery.class:6
PostgresQuery
Definição
mquery.class:7
PostgresQuery\__construct
__construct()
Definição
mquery.class:20
PostgresQuery\_close
_close()
Definição
mquery.class:79
PostgresQuery\_setmetadata
_setmetadata()
Definição
mquery.class:92
PostgresQuery\_error
_error()
Definição
mquery.class:67
PostgresQuery\_query
_query()
Definição
mquery.class:32
PostgresQuery\$id_result
$id_result
Definição
mquery.class:11
PostgresQuery\_getmetatype
_getmetatype($type)
Definição
mquery.class:116
sql
Definição
compatibility.class:18
classes
database
postgres
mquery.class
Gerado por
1.10.0