forked from apaoww/yii2-oci8
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColumnSchema.php
More file actions
51 lines (45 loc) · 1.44 KB
/
ColumnSchema.php
File metadata and controls
51 lines (45 loc) · 1.44 KB
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
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace apaoww\oci8;
//use yii\base\Object;
/**
* ColumnSchema class describes the metadata of a column in a database table.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class ColumnSchema extends \yii\db\ColumnSchema
{
/**
* Converts the input value according to [[phpType]] after retrieval from the database.
* If the value is null or an [[Expression]], it will not be converted.
* @param mixed $value input value
* @return mixed converted value
* @since 2.0.3
*/
protected function typecast($value)
{
if ($value === '' && $this->type !== Schema::TYPE_TEXT && $this->type !== Schema::TYPE_STRING && $this->type !== Schema::TYPE_BINARY) {
return null;
}
if ($value === null || gettype($value) === $this->phpType || $value instanceof Expression) {
return $value;
}
switch ($this->phpType) {
case 'resource':
case 'string':
return is_resource($value) ? $value : (string) $value->load();//oracle clob need this
case 'integer':
return (int) $value;
case 'boolean':
return (bool) $value;
case 'double':
return (double) $value;
}
return $value;
}
}