@@ 29-52 (lines=24) @@ | ||
26 | ||
27 | namespace ntentan\nibii\adapters; |
|
28 | ||
29 | class MysqlAdapter extends \ntentan\nibii\DriverAdapter |
|
30 | { |
|
31 | public function mapDataTypes($nativeType) |
|
32 | { |
|
33 | switch ($nativeType) { |
|
34 | case 'int': |
|
35 | return 'integer'; |
|
36 | case 'varchar': |
|
37 | return 'string'; |
|
38 | case 'tinyint': |
|
39 | return 'boolean'; |
|
40 | case 'timestamp': |
|
41 | case 'datetime': |
|
42 | return 'datetime'; |
|
43 | case 'text': |
|
44 | return 'text'; |
|
45 | case 'date': |
|
46 | return 'date'; |
|
47 | default: |
|
48 | throw new \Exception("Unknown type {$nativeType}"); |
|
49 | } |
|
50 | } |
|
51 | } |
|
52 |
@@ 29-60 (lines=32) @@ | ||
26 | ||
27 | namespace ntentan\nibii\adapters; |
|
28 | ||
29 | class PostgresqlAdapter extends \ntentan\nibii\DriverAdapter |
|
30 | { |
|
31 | /** |
|
32 | * Convert from postgresqls native type to a generic type accepted in the |
|
33 | * atiaa library. |
|
34 | * |
|
35 | * @param string $nativeType |
|
36 | * |
|
37 | * @throws \Exception |
|
38 | * |
|
39 | * @return string |
|
40 | */ |
|
41 | public function mapDataTypes($nativeType) |
|
42 | { |
|
43 | switch ($nativeType) { |
|
44 | case 'character varying': |
|
45 | return 'string'; |
|
46 | case 'text': |
|
47 | return 'text'; |
|
48 | case 'date': |
|
49 | return 'date'; |
|
50 | case 'integer': |
|
51 | case 'boolean': |
|
52 | return $nativeType; |
|
53 | case 'numeric': |
|
54 | return 'double'; |
|
55 | case 'timestamp without time zone': |
|
56 | case 'timestamp with time zone': |
|
57 | return 'datetime'; |
|
58 | default: |
|
59 | throw new \Exception("Unknown type {$nativeType}"); |
|
60 | } |
|
61 | } |
|
62 | } |
|
63 |