| @@ 953-967 (lines=15) @@ | ||
| 950 | * @param string $type The sqlite type name. |
|
| 951 | * @return mixed Returns $value cast to the appropriate type. |
|
| 952 | */ |
|
| 953 | protected function forceType($value, $type) { |
|
| 954 | $type = strtolower($type); |
|
| 955 | ||
| 956 | if ($type === 'null') { |
|
| 957 | return null; |
|
| 958 | } elseif (in_array($type, ['int', 'integer', 'tinyint', 'smallint', |
|
| 959 | 'mediumint', 'bigint', 'unsigned big int', 'int2', 'int8', 'boolean'])) { |
|
| 960 | return force_int($value); |
|
| 961 | } elseif (in_array($type, ['real', 'double', 'double precision', 'float', |
|
| 962 | 'numeric', 'decimal(10,5)'])) { |
|
| 963 | return floatval($value); |
|
| 964 | } else { |
|
| 965 | return (string)$value; |
|
| 966 | } |
|
| 967 | } |
|
| 968 | } |
|
| 969 | ||
| @@ 260-274 (lines=15) @@ | ||
| 257 | * @param string $type The sqlite type name. |
|
| 258 | * @return mixed Returns $value cast to the appropriate type. |
|
| 259 | */ |
|
| 260 | protected function forceType($value, $type) { |
|
| 261 | $type = strtolower($type); |
|
| 262 | ||
| 263 | if ($type === 'null') { |
|
| 264 | return null; |
|
| 265 | } elseif (in_array($type, ['int', 'integer', 'tinyint', 'smallint', |
|
| 266 | 'mediumint', 'bigint', 'unsigned big int', 'int2', 'int8', 'boolean'])) { |
|
| 267 | return force_int($value); |
|
| 268 | } elseif (in_array($type, ['real', 'double', 'double precision', 'float', |
|
| 269 | 'numeric', 'decimal(10,5)'])) { |
|
| 270 | return floatval($value); |
|
| 271 | } else { |
|
| 272 | return (string)$value; |
|
| 273 | } |
|
| 274 | } |
|
| 275 | ||
| 276 | /** |
|
| 277 | * Get the columns for tables and put them in {MySqlDb::$tables}. |
|