MIOLO20
Tudo Estruturas de dados Namespaces Ficheiros Funções Variáveis
mquery.class
Ir para a documentação deste ficheiro.
1<?php
2
3class ODBCQuery extends MQuery
4{
6
7 function __construct()
8 {
9 parent::__construct();
10 }
11
12 function _query()
13 {
14 $this->fetched = false;
15 $this->sql = $this->maxrows ? $this->sql . " LIMIT $this->maxrows" : $this->sql;
16 $this->sql = $this->offset ? $this->sql . " OFFSET $this->offset" : $this->sql;
17 $this->id_result = odbc_exec($this->conn->id, $this->sql);
18 $this->error = $this->_error();
19
20 if (!$this->error)
21 {
22 $this->rowCount = odbc_num_rows($this->id_result);
23
24 for ($n = 0; $n < $this->rowCount; $this->result[$n++] = odbc_fetch_array($this->id_result,$n));
25
26 $this->fetched = true;
27 $this->colCount = odbc_num_fields($this->id_result);
28 }
29 else
30 {
31 throw new EDatabaseQueryException($this->error);
32 }
33
34 return (!$this->error);
35 }
36
37 function _error()
38 {
39 return (($error = odbc_error($this->conn->id)) ? odbc_errormsg($this->conn->id) : false);
40 }
41
42 function _close()
43 {
44 if ($this->id_result)
45 {
47 unset ($this->id_result);
48 }
49 }
50
51 function _setmetadata()
52 {
53 $numCols = $this->colCount;
54 $this->metadata = array();
55 for ($i = 1; $i <= $numCols; $i++)
56 {
57 $name = strtoupper(odbc_field_name($this->id_result, $i));
58 $name = ($p = strpos($name, '.')) ? substr($name, $p + 1) : $name;
59 $this->metadata['fieldname'][$i - 1] = $name;
60 $this->metadata['fieldtype'][$name] = $this->_getmetatype(strtoupper(odbc_field_name($this->id_result, $i)));
61 $this->metadata['fieldlength'][$name] = odbc_field_len($this->id_result, $i);
62 $this->metadata['fieldpos'][$name] = $i - 1;
63 }
64 }
65
67 {
69 $rType = 'N';
70
71 if ($type == "VARCHAR")
72 {
73 $rType = 'C';
74 }
75 elseif ($type == "CHAR")
76 {
77 $rType = 'C';
78 }
79 elseif ($type == "NUMBER")
80 {
81 $rType = 'N';
82 }
83 elseif ($type == "INTEGER")
84 {
85 $rType = 'N';
86 }
87 elseif ($type == "DATE")
88 {
89 $rType = 'T';
90 }
91 elseif ($type == "TIMESTAMP")
92 {
93 $rType = 'T';
94 }
95
96 return $rType;
97 }
98}
99?>
$error
Definição mquery.class:7
__construct()
Definição mquery.class:7
_setmetadata()
Definição mquery.class:51
_getmetatype($type)
Definição mquery.class:66