1 | <?php |
||
11 | trait OrmDataTypeConverter |
||
12 | { |
||
13 | /** |
||
14 | * Include some basic utility functions |
||
15 | */ |
||
16 | use OrmUtil; |
||
17 | |||
18 | /** |
||
19 | * Convert a date string into DateTime object |
||
20 | * |
||
21 | * Accepted values are (in this order) |
||
22 | * |
||
23 | * - Unix timestamp |
||
24 | * - Single ISO8601 date |
||
25 | * - Simple ISO8601 date and time without timezone |
||
26 | * - DateTime::W3C |
||
27 | * - DateTime::ISO8601 |
||
28 | * |
||
29 | * @param string $value |
||
30 | */ |
||
31 | 14 | private static function convertDate($value) |
|
57 | |||
58 | /** |
||
59 | * Convert arbitrary data into given type |
||
60 | * |
||
61 | * @param string $type The type to convert data into |
||
62 | * @param mixed $value The value to convert |
||
63 | * @throws OrmException |
||
64 | * |
||
65 | * @return mixed The converted data |
||
66 | */ |
||
67 | 26 | private static function convertType($type, $value) |
|
111 | |||
112 | /** |
||
113 | * Retrieve the type of column in database |
||
114 | * |
||
115 | * @param Orm $orm Orm instance |
||
116 | * @param string $table The table where the column is part of |
||
117 | * @param string $columnName The name of column to retrieve datatype of |
||
118 | * |
||
119 | * @return int The datatype of column in database table |
||
120 | */ |
||
121 | 11 | private static function getColumnType(Orm $orm, $table, $columnName) |
|
125 | |||
126 | /** |
||
127 | * Convert type into database type representation |
||
128 | * |
||
129 | * @param integer $type The type to convert from |
||
130 | * @param mixed $value The value to convert from |
||
131 | * |
||
132 | * @return mixed The converted value data |
||
133 | */ |
||
134 | 11 | private static function convertToDatabaseType($type, $value) |
|
163 | } |
||
164 |