-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_TcDB.php
More file actions
executable file
·511 lines (448 loc) · 27 KB
/
_TcDB.php
File metadata and controls
executable file
·511 lines (448 loc) · 27 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
<?PHP
/*-------------------------------------------------------------------------------
Mantenedor : Rodrigo Dittmar
Linguaguem : php 7.x
Dependencias : Class(TcDebug)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Modulo : Coneccao ao Banco de dados / Manutencao de Dados
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Mantenedor : Rodrigo Dittmar
Classe : TcDB
Descricao : Coneccao com o Banco de Dados / Execucao de Query
--------------------------------------------------------------------------------
Versao 1.0.0.0 : 20051201 - Liberacao do Codigo
Versao 1.0.1.0 : 20060401 - Otimizacao do Codigo
Versao 1.1.0.0 : 20060501 - Otimizacao do Codigo, Inclusao de SQL
Versao 1.2.0.0 : 20061001 - Otimizacao do Codigo
Versao 1.2.0.1 : 20061215 - Correcao Retorno Campos Blob Firebird
Versao 1.3.0.0 : 20070331 - Otimizacao do Codigo/Codificacao de Erros/Desmembramento Manutencao Dados
Versao 1.3.0.5 : 20070630 - Correcao Codificacao Erros/Definicao do Log Debug em Niveis
Niveis de Debug
0 - Construtores / Destrutores
1 - Conexao ao DB
2 - Recuperacao de Dados do DB
7 - Erros
9 - Auxiliares / Privadas / Sem muita importancia
Versao 1.4.0.0 : 20120601 - Otimizacao do Codigo
Versao 1.0.1.0 : 2019 - Adaptação para o projeto CLibras
------------------------------------------------------------------------------*/
Class TcDB {
private $FConfig = array(); //Dados de Coneccao ao Servidor
public $FCon = false; //Recurso para a coneccao ao DB
private $FConnected = false; //Conectado ao DB (true/false)
public $FError = array(); //Armazena os Erros na Execucao do SQL (Funcao / Codigo / Mensagem / Historico)
private $FOwner = ''; //Proprietario
private $FDebug; //recurso para gravar log do debug
private $FWrite = array(); //Niveis de gravacao do debug
/*----------------------------------------------------------------------------
__construct(0) : Cria a classe e atualiza os atributos
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
aOwner :string : Proprietario do Objeto
aConfig :array : Array de Configuração (modelo $esDB)
a :&tcDebug : Objeto Debug
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
----------------------------------------------------------------------------*/
function __construct( $aOwner = '' , $aConfig = false , &$aDebug = false ) {
//Definindo as propriedades do objeto
$this -> FOwner = $aOwner;
$this -> FDebug = $aDebug;
$this -> FWrite = array(0,0,0,0,0,0,0,0,0,0);
//Setando os parametros da classe -- Apenas o que for necessário alterar
if( is_array($aConfig) ) {
foreach ($aConfig as $a=>$b) {
$this -> FConfig[strtolower($a)] = $b;
};
}
//Definindo os Niveis de Backup
if( is_object($this -> FDebug) ) {
$this -> FWrite = $this -> FDebug -> FWrite;
$this -> logDebug( __METHOD__ , 'Debug Level :' . implode($this -> FWrite,",") );
}
}
/*----------------------------------------------------------------------------
__destruct(0) : Libera a memoria alocada e encerra a coneccao
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
----------------------------------------------------------------------------*/
function __destruct() {
//Fechando a Coneccao ao DB
if( $this -> FConnected )
$this -> close();
if( $this -> FWrite[0] ) $this -> logDebug( __METHOD__ );
}
/*----------------------------------------------------------------------------
logDebug : Armazena o Log de Debug
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
aFunction :string : Evento da Classe
aDes :string : Descricao do Evento
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
----------------------------------------------------------------------------*/
function logDebug( $aFunction , $aDes = '' ) {
$this -> FDebug -> write( $this -> FOwner, $aFunction , $aDes );
}
/*------------------=-----------=---------------------------------------------------------------------------=
status : Retorna o satus da classe
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-----------------------------------------------------------------------------------------------------------*/
function status( ) {
$aDB = array();
$aDB[0] = "ES_DBFILE";
$aDB[1] = "ES_DBMYSQL40";
$aDB[2] = "ES_DBMYSQL41";
$aDB[3] = "ES_DBFIREBIRD";
$a ="<div><Table><tr><th>Item</th><th>Valor</th></tr>";
//configurações do banco de dados
foreach($this -> FConfig as $b=>$c) {
$a=$a . "<tr><td>$b</td><td>" . ($b=="pass"?"******":($b=="type"?$aDB[$c]:$c)) . "</td>";
}
//Status da conecção
$this -> connect();
$a=$a . "<tr><td>Connected</td><td>" . ($this -> FConnected?"OK":"Not Connected") . "</td>";
$a=$a . "</tr></table></div>";
return $a;
}
/*============================================================================
Coneccao ao Banco de Dados
/*----------------------------------------------------------------------------
connect(1) : Conecta e Seleciona o banco de dados - Coneccao Permanente
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
----------------------------------------------------------------------------*/
function connect() {
//Conectando ao DB se não conectado
if( !($this -> FConnected) ) {
if( $this -> FWrite[1] )
$this -> logDebug( __METHOD__ , $this -> FConfig['user'] .'@'. $this -> FConfig['host'] .':'. $this -> FConfig['db'] );
if( $this -> FConfig['type'] == ES_DBMYSQL40 ) {
$this -> FCon = @mysql_connect( $this -> FConfig['host'] , $this -> FConfig['user'] , $this -> FConfig['pass'] );
if ( ($this -> FCon) and ( !@mysql_select_db($this -> FConfig['db'] , $this -> FCon) ) ) {
mysql_close($this->FCon);
$this -> FCon = false;
}
} else if( $this -> FConfig['type'] == ES_DBMYSQL41 ) {
$this -> FCon = @mysqli_connect( $this -> FConfig['host'] , $this -> FConfig['user'] , $this -> FConfig['pass'] , $this -> FConfig['db'] );
} else if( $this -> FConfig['type'] == ES_DBFIREBIRD ) {
$this -> FCon = @ibase_connect( $this -> FConfig['host'] .":". $this -> FConfig['db'] , $this -> FConfig['user'] , $this -> FConfig['pass'] , 'ISO8859_1' );
}
$this -> error( __METHOD__ );
$this -> FConnected = ($this -> FCon?true:false);
}
return( $this -> FConnected );
}
/*----------------------------------------------------------------------------
close(1) : Encerra a coneccao com o Servidor
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:boolean : Conectado ou nao ( True / False )
----------------------------------------------------------------------------*/
function close() {
if( $this -> FConnected ) {
if( $this -> FWrite[1] ) $this -> logDebug( __METHOD__ );
switch ($this -> FConfig['type']) {
case ES_DBMYSQL40 : mysql_close( $this -> FCon ); break;
case ES_DBMYSQL41 : mysqli_close( $this -> FCon ); break;
case ES_DBFIREBIRD : ibase_close( $this -> FCon ); break;
}
$this -> error( __METHOD__ );
}
$this -> FCon = false;
$this -> FConnected = false;
}
/*----------------------------------------------------------------------------
connected(9) : Retorna se houve coneccao ao DB
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:boolean : Conectado ou nao ( True / False )
----------------------------------------------------------------------------*/
function connected() {
if( $this -> FWrite[9] ) $this -> logDebug( __METHOD__ , ( $this -> FConnected ) );
return( $this -> FConnected );
}
/*----------------------------------------------------------------------------
get_Host_Type(9) : Retorna o tipo de servidor conectado
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:integer : Tipo de coneccao
----------------------------------------------------------------------------*/
function get_Host_Type() {
if( $this -> FWrite[9] ) {
$a = array ("ES_DBFILE" ,"ES_DBMYSQL40","ES_DBMYSQL41" ,"ES_DBFIREBIRD" );
$this -> logDebug( __METHOD__ , $a[$this -> FConfig['type']] );
}
return( $this -> FConfig['type'] );
}
/*============================================================================
Manutencao dos Recursos
/*----------------------------------------------------------------------------
query(2) : Executa uma query
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
aQuery :string : Query SQL
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:recurso : Recurso de retorno dos Dados
----------------------------------------------------------------------------*/
function query( $aQuery = '') {
$result = false;
if( $this -> FWrite[2] )
$this -> logDebug( __METHOD__ , $aQuery );
//Verifica se ha coneccao e inicia se nao houver.
if( !$this -> FConnected ) $this -> connect();
switch( $this -> FConfig['type'] ) {
case ES_DBMYSQL40 : $result = @mysql_query( $aQuery , $this -> FCon ); break;
case ES_DBMYSQL41 : $result = $this -> FCon -> query( $aQuery ); break;
case ES_DBFIREBIRD : $result = @ibase_query( $this -> FCon , str_replace( "\'", "''" , $aQuery ) ); break;
}
return( $result );
}
/*---------------------------------------------------------------------------------------------------------
error(2) : Recupera o Codigo e Mensagem de Erro do Banco de Dados e armazena no vetor
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
aFunction :string : Nome da Funcao de Erro
aHistory :string : Codigo/Opcao do Erro
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---------------------------------------------------------------------------------------------------------*/
function error( $aFunction , $aHistory = '' ) {
$aError = array(0,"",0,"","");
if( $this -> connected() ) {
switch( $this -> FConfig['type'] ) {
case ES_DBMYSQL40 : $aError = array( microtime(true), $aFunction , @mysql_errno($this -> FCon) , @mysql_error($this -> FCon) , $aHistory ); break;
case ES_DBMYSQL41 : $aError = array( microtime(true), $aFunction , @mysqli_errno($this -> FCon) , @mysqli_error($this -> FCon) , $aHistory ); break;
case ES_DBFIREBIRD : $aError = array( microtime(true), $aFunction , ibase_errcode() , ibase_errmsg() , $aHistory ); break;
}
} else {
switch( $this -> FConfig['type'] ) {
case ES_DBMYSQL40 : $aError = array( microtime(true), $aFunction , @mysql_errno($this -> FCon) , @mysql_error($this -> FCon) , $aHistory ); break;
case ES_DBMYSQL41 : $aError = array( microtime(true), $aFunction , @mysqli_connect_errno() , @mysqli_connect_error() , $aHistory ); break;
case ES_DBFIREBIRD : $aError = array( microtime(true), $aFunction , ibase_errcode() , ibase_errmsg() , $aHistory ); break;
}
}
if( $aError[1] <> 0 ) {
$this -> FError[] = $aError;
if( $this -> FWrite[2] ) $this -> logDebug( __METHOD__ , 'ERROR: ' . explode( $this -> FError[count($this -> FError) -1],"," ) );
return( true );
}
}
}
/*-------------------------------------------------------------------------------------------------------------
Mantenedor : Rodrigo Dittmar
Classe : TcQuery_light
Descricao : Execucao e Manutencao dados Query
---------------------------------------------------------------------------------------------------------------
Versao 1.0.0.0 : 20070331 - Liberacao do Codigo
Versao 1.0.0.5 : 20070630 - Correcao Codificacao Erros/Definicao do Log Debug em Niveis
Niveis de Debug
0 - Construtores / Destrutores
1 - Conexao ao DB
2 - Recuperacao de Dados do DB / Query
5 - Recuperacao de Dados do DB / fetch_row / get_col
7 - Erros
9 - Auxiliares / Privadas / Sem muita importancia
Versao 1.4.0.0 : 20120601 - Otimizacao do Codigo
Versao 1.5.0.0 : 2019 -
-------------------------------------------------------------------------------------------------------------*/
Class TcQuery_light {
private $FHostCon; //Classe TcDB p/Coneccao ao DB
private $FConfigType; //Tipo de banco de dados
private $FResult; //Objeto resultado da execucao da query
private $FSQL = ''; // Código SQL
private $FSQL_Param = array(); // Parametros do SQL
private $FOwner = ''; //Proprietario
private $FDebug = false; //recurso para gravar log do debug
private $FLog = array(); //Niveis de gravacao do log/debug
/*------------------=-----------=----------------------------------------------------------------------------
__construct(0) : Cria a classe e atualiza os atributos
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
aOwner :string : Proprietario do Objeto
aTcDB :&TcDB : Objeto Banco de Dados
aTcDebug :&tcDebug : Objeto Debug
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-----------------------------------------------------------------------------------------------------------*/
function __construct( $aOwner = '' , &$aTcDB , &$aTcDebug = false ) {
$this -> FOwner = $aOwner; // Proprietario
$this -> FHostCon = $aTcDB; // Objeto TcDB
$this -> FDebug = $aTcDebug; // Objeto TcDebug
$this -> FLog = array(0,0,0,0,0,0,0,0,0,0); //Nivel do Log/Debug
// Recuperando o tipo de Banco de Dados
$this -> FConfigType = $this -> FHostCon -> get_Host_Type();
$this -> FResult = false;
//Definindo os Niveis de Backup
if( is_object($this -> FDebug) ) {
$this -> FLog = $this -> FDebug -> FWrite;
$this -> log( __METHOD__ , 'Debug Level :' . implode($this -> FLog,",") );
}
}
/*------------------=-----------=----------------------------------------------------------------------------
__destruct(0) : Libera a memoria alocada e encerra a conexao
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-----------------------------------------------------------------------------------------------------------*/
function __destruct() {
//Limpando o Resultado
$this -> freeResult();
if( $this -> FLog[0] ) $this -> log( __METHOD__ );
}
/*------------------=-----------=----------------------------------------------------------------------------
log : Armazena o Log de Debug
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
aClass :string : Classe
aFunction :string : Evento da Classe
aDes :string : Descricao do Evento
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-----------------------------------------------------------------------------------------------------------*/
function log( $aFunction , $aDes = '' ) {
$this -> FDebug -> log( $this -> FOwner, $aFunction , $aDes );
}
/*===========================================================================================================
Manutencao dos Recursos e Conexao ao DB
/*------------------=-----------=----------------------------------------------------------------------------
connect(5) : Conecta ao DB retornando true/false
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:boolean : Sucesso/Fracasso
-----------------------------------------------------------------------------------------------------------*/
function connect() {
if( $this -> FLog[5] ) $this -> log( __METHOD__ );
return( $this -> FHostCon -> connect() );
}
/*------------------=-----------=----------------------------------------------------------------------------
freeResult(5) : Limpa o resultado gerado pela query
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:boolean : Sucesso ou Fracasso ( True / False )
-----------------------------------------------------------------------------------------------------------*/
function freeResult() {
if( $this -> FLog[5] ) $this -> log( __METHOD__ );
if( is_resource($this -> FResult) or is_object($this -> FResult) ) {
switch( $this -> FConfigType ) {
case ES_DBMYSQL40 : @mysql_free_result( $this -> FResult ); break;
case ES_DBMYSQL41 : @mysqli_free_result( $this -> FResult ); break;
case ES_DBFIREBIRD : @ibase_free_result( $this -> FResult ); break;
}
}
return( $this -> error( __METHOD__ ) );
}
/*------------------=-----------=----------------------------------------------------------------------------
query(2) : Executa uma query diretamente
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
aQuery :string : Query SQL
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:boolean : Sucesso/Fracasso
-----------------------------------------------------------------------------------------------------------*/
function query( $aQuery ) {
if( $this -> FLog[2] ) $this -> log( __METHOD__ , $aQuery );
//Verifica se ha coneccao e inicia se nao houver.
if ( $this -> connect() ) {
switch( $this -> FConfigType ) {
case ES_DBMYSQL40 : $this -> FResult = @mysql_query( $aQuery , $this -> FHostCon -> FCon ); break;
case ES_DBMYSQL41 : $this -> FResult = $this -> FHostCon -> FCon -> query( $aQuery ); break;
case ES_DBFIREBIRD : $this -> FResult = @ibase_query( $this -> FHostCon -> FCon , str_replace( "\'", "''" , $aQuery ) ); break;
}
} else
if( $this -> FWrite[2] ) $this -> FDebug -> log( $this -> FOwner , __METHOD__ , 'Error in conection!' );
return( $this -> error( __METHOD__ , $aQuery ) );
}
/*------------------=-----------=----------------------------------------------------------------------------
fetchRow(5) : Retorna linha a linha o resultado da query
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
aType :boolean : Tipo de Retorno (True -> Indice / False -> Coluna)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:array : Array de dados
-----------------------------------------------------------------------------------------------------------*/
function fetchRow( $aType = False ) {
$aReturn = false;
//Recurso do DB
if( is_resource($this -> FResult) or is_object($this -> FResult) ) {
switch( $this -> FConfigType ) {
case ES_DBMYSQL40 : $aReturn = ($aType ? mysql_fetch_row( $this -> FResult ) : mysql_fetch_assoc( $this -> FResult ) ); break;
case ES_DBMYSQL41 : $aReturn = ($aType ? mysqli_fetch_row( $this -> FResult ) : mysqli_fetch_assoc( $this -> FResult ) ); break;
case ES_DBFIREBIRD : $aReturn = ($aType ? ibase_fetch_row( $this -> FResult , IBASE_TEXT ) : ibase_fetch_assoc( $this -> FResult , IBASE_TEXT ) );
}
if ( !$aType and is_array($aReturn) )
$aReturn = array_change_key_case( $aReturn , CASE_LOWER );
}
if( $this -> FLog[5] ) $this -> log( __METHOD__ , $aReturn );
return( $aReturn );
}
/*------------------=-----------=----------------------------------------------------------------------------
getCol(5 ) : Retorna as Colunas,tipo do resultado de uma query
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
aReturn : Array das Colunas de retorno
-----------------------------------------------------------------------------------------------------------*/
function getCol( ) {
$aReturn = array(); //Armazena as Colunas
$aFields = 0; //Numero de Colunas (firebird)
$aHostType = $this -> FConfigType;
if( is_resource($this -> FResult) or is_object($this -> FResult) )
if ( $aHostType == ES_DBMYSQL40 ) {
while( $ColInfo = mysql_fetch_field( $this -> FResult ) )
$aReturn[$ColInfo->name] = array( $this->dataType( $ColInfo->type ) );
} elseif ( $aHostType == ES_DBMYSQL41 ) {
while( $ColInfo = mysqli_fetch_field( $this -> FResult ) )
$aReturn[$ColInfo->name] = array( $this->dataType( $ColInfo->type ) );
} elseif ( $aHostType == ES_DBFIREBIRD ) {
$aFields = ibase_num_fields( $this -> FResult );
for( $i=0 ; $i < $aFields ; $i++ ) {
$ColInfo = ibase_field_info( $this -> FResult , $i );
$aReturn[$ColInfo['alias']] = array( $this->dataType( $ColInfo['type'] ) );
}
}
if ( is_array($aReturn) )
$aReturn = array_change_key_case( $aReturn , CASE_LOWER );
if( $this -> FLog[5] ) $this -> log( __METHOD__ , $aReturn );
return( $aReturn );
}
/*===========================================================================================================
Manutencao dos Erros
/*------------------=-----------=----------------------------------------------------------------------------
error(2) : Adiciona um erro a classe TcDB - se houver
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
aFunction :string : Nome da Funcao de Erro
aHistory :string : Codigo/Opcao do Erro
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:boolean : Houve ou nao Erro (True / False)
-----------------------------------------------------------------------------------------------------------*/
function error( $aFunction , $aHistory = '' ) {
if( $this -> FLog[2] ) $this -> log( __METHOD__ );
return( $this -> FHostCon -> error( $aFunction , $aHistory ) );
}
/*------------------=-----------=----------------------------------------------------------------------------
getError(2) : Recupera o ultimo erro
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:Array : Ultimo erro
-----------------------------------------------------------------------------------------------------------*/
function getError( ) {
if( $this -> FLog[2] ) $this -> log( __METHOD__ , $this -> FHostCon -> FError[ count($this -> FHostCon -> FError) -1 ] );
//Busca no TcDB o erro e se houver armazena-o
return( $this -> FHostCon -> FError[ count($this -> FHostCon -> FError) -1 ] );
}
/*===========================================================================================================
Funcoes privadas do sistema
/*------------------=-----------=----------------------------------------------------------------------------
data_Type(9) : Converte o Tipo de Dados para a Definicao do sistema
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
aType :string : Tipo de dados
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ES_VB* :DEFINITION : Definicao para o tipo de dados resultante
-----------------------------------------------------------------------------------------------------------*/
private function data_Type( $aType ) {
$aType = strtoupper($aType);
if( $this -> FLog[9] ) $this -> log( __METHOD__ , $aType );
if ( ( $aType == 'INTEGER' ) or ( $aType == 'INT' ) )
return ES_VBINTEGER;
else if ($aType == 'DOUBLE')
return ES_VBDOUBLE;
else if ( ( $aType == 'VARCHAR' ) or ( $aType == 'CHAR' ) or ( $aType == 'STRING' ) )
return ES_VBVARCHAR;
else if ($aType == 'DATE')
return ES_VBDATE;
else if ($aType == 'TIME')
return ES_VBTIME;
else if ($aType == 'BLOB')
return ES_VBBLOB;
else
return ES_VBUNKNOW;
}
}