-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.php
53 lines (49 loc) · 1.15 KB
/
functions.php
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
<?php
// Funções de Apoio
function pr($mixed) {
echo '<pre>';
print_r($mixed);
echo '</pre>';
}
// Tipos de colunas e conversão para mySQL
function mysql_types( $name,$type,$size ) {
switch( $type ) {
case 'VARCHAR2':
return ( 'VARCHAR('.$size.')' );
break;
case 'NUMBER':
return( 'INT' );
break;
case 'CHAR':
if (substr($name,0,3) == 'DT_')
return( 'DATE' );
else
return ( 'VARCHAR('.$size.')' );
break;
default:
return ( '' );
break;
}
}
function mysql_col_types( $text, $coluna = array() ) {
list($name,$size,$ini,$end,$type) = $coluna;
$ini--;
switch ( $type ) {
case 'VARCHAR2':
return ( utf8_encode( '"'.trim( substr( $text, $ini, $size ) ).'"' ) );
break;
case 'NUMBER':
return ( utf8_encode( substr( $text, $ini, $size ) ) );
break;
case 'CHAR':
if (substr($name,0,3) == 'DT_')
$ret = utf8_encode( '"'.substr( $text, $ini, $size-2 ).'-'.substr( $text, $ini+4, $size-4 ).'-01"' );
else
$ret = utf8_encode( '"'.trim( substr( $text, $ini, $size ) ).'"' );
return ( $ret );
break;
default:
return ( utf8_encode( '"'.trim( substr( $text, $ini, $size ) ).'"' ) );
break;
}
}