@@ 4-27 (lines=24) @@ | ||
1 | <?php |
|
2 | namespace ntentan\nibii\adapters; |
|
3 | ||
4 | class MysqlAdapter extends \ntentan\nibii\DriverAdapter |
|
5 | { |
|
6 | public function mapDataTypes($nativeType) |
|
7 | { |
|
8 | switch($nativeType) |
|
9 | { |
|
10 | case 'int': |
|
11 | return 'integer'; |
|
12 | case 'varchar': |
|
13 | return 'string'; |
|
14 | case 'tinyint': |
|
15 | return 'boolean'; |
|
16 | case 'timestamp': |
|
17 | case 'datetime': |
|
18 | return 'datetime'; |
|
19 | case 'text': |
|
20 | return 'text'; |
|
21 | case 'date': |
|
22 | return 'date'; |
|
23 | default: |
|
24 | throw new \Exception("Unknown type {$nativeType}"); |
|
25 | } |
|
26 | } |
|
27 | } |
|
28 |
@@ 4-35 (lines=32) @@ | ||
1 | <?php |
|
2 | namespace ntentan\nibii\adapters; |
|
3 | ||
4 | class PostgresqlAdapter extends \ntentan\nibii\DriverAdapter |
|
5 | { |
|
6 | /** |
|
7 | * Convert from postgresqls native type to a generic type accepted in the |
|
8 | * atiaa library. |
|
9 | * @param string $nativeType |
|
10 | * @return string |
|
11 | * @throws \Exception |
|
12 | */ |
|
13 | public function mapDataTypes($nativeType) |
|
14 | { |
|
15 | switch($nativeType) |
|
16 | { |
|
17 | case 'character varying': |
|
18 | return 'string'; |
|
19 | case 'text': |
|
20 | return 'text'; |
|
21 | case 'date': |
|
22 | return 'date'; |
|
23 | case 'integer': |
|
24 | case 'boolean': |
|
25 | return $nativeType; |
|
26 | case 'numeric': |
|
27 | return 'double'; |
|
28 | case 'timestamp without time zone': |
|
29 | case 'timestamp with time zone': |
|
30 | return 'datetime'; |
|
31 | default: |
|
32 | throw new \Exception("Unknown type {$nativeType}"); |
|
33 | } |
|
34 | } |
|
35 | } |
|
36 |