MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mquery.class
Ir para a documentação deste ficheiro.
1<?php
6class PostgresQuery extends MQuery
7{
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)
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
117 {
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?>
_getmetatype($type)
Definição mquery.class:116