blob: 284a5fd23d25c3e9fab1b8660824f993aa32a6ce (
plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
<?php
/**
* TIbmColumnMetaData class file.
*
* @author Cesar Ramos <cramos[at]gmail[dot]com>
* @link http://www.pradosoft.com/
* @copyright Copyright © 2005-2007 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id: TIbmColumnMetaData.php 1807 2007-03-31 06:42:15Z wei $
* @package System.Data.ActiveRecord.Vendor
*/
/**
* TIbmColumnMetaData class.
*
* Column details for IBM DB2 database. Using php_pdo_ibm.dll extension.
*
* @author Cesar Ramos <cramos[at]gmail[dot]com>
* @version $Id: TIbmColumnMetaData.php 1807 2007-03-31 06:42:15Z wei $
* @package System.Data.ActiveRecord.Vendor
* @since 3.1
*/
class TIbmColumnMetaData extends TComponent
{
private $_name;
private $_type;
private $_length;
private $_autoIncrement;
private $_default;
private $_notNull=true;
private $_isPrimary=null;
private $_property;
/**
* Initialize column meta data.
*
* @param string column name.
* @param string column data type.
* @param string column data length.
* @param boolean column can not be null.
* @param string serial name.
* @param string default value.
*/
public function __construct($name,$type,$length,$notNull,$autoIncrement,$default,$primary)
{
$this->_property=$name;
$this->_name=$name;
$this->_type=$type;
$this->_length=$length;
$this->_notNull=$notNull;
$this->_autoIncrement=$autoIncrement;
$this->_default=$default;
$this->_isPrimary=$primary;
}
/**
* @return string quoted column name.
*/
public function getName()
{
return $this->_name;
}
/**
* @return integer length.
*/
public function getLength()
{
return $this->_length;
}
/**
* @return string active record property name
*/
public function getProperty()
{
return $this->_property;
}
/**
* @return boolean true if column is a sequence, false otherwise.
*/
public function hasSequence()
{
return $this->_autoIncrement;
}
/**
* @return null no sequence name.
*/
public function getSequenceName()
{
return null;
}
/**
* @return boolean true if the column is a primary key, or part of a composite primary key.
*/
public function getIsPrimaryKey()
{
return $this->_isPrimary;
}
/**
* @return string column type
*/
public function getType()
{
return $this->_type;
}
/**
* @return boolean false if column can be null, true otherwise.
*/
public function getNotNull()
{
return $this->_notNull;
}
/**
* @return boolean true if column has default value, false otherwise.
*/
public function hasDefault()
{
return $this->_default !== null;
}
/**
* @return string default column value.
*/
public function getDefaultValue()
{
return $this->_default;
}
/**
* @return string PHP primative type derived from the column type.
*/
public function getPHPType()
{
switch(strtolower($this->_type))
{
case 'smallint': case 'integer':
return 'integer';
case 'real': case 'float': case 'double': case 'decimal': case 'bigint':
return 'float';
default:
return 'string';
}
}
}
?>
|