## Apache Zeta Components Manual :: File Source for field.php

## Source for file field.php

Documentation is available at field.php

1. <?php
2. /**
3. *
4. * Licensed to the Apache Software Foundation (ASF) under one
5. * or more contributor license agreements. See the NOTICE file
6. * distributed with this work for additional information
7. * regarding copyright ownership. The ASF licenses this file
8. * to you under the Apache License, Version 2.0 (the
9. * "License"); you may not use this file except in compliance
10. * with the License. You may obtain a copy of the License at
11. *
12. * http://www.apache.org/licenses/LICENSE-2.0
13. *
14. * Unless required by applicable law or agreed to in writing,
15. * software distributed under the License is distributed on an
16. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17. * KIND, either express or implied. See the License for the
18. * specific language governing permissions and limitations
19. * under the License.
20. *
21. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
22. * @version //autogentag//
23. * @filesource
24. * @package DatabaseSchema
25. */
26. /**
27. * A container to store a field definition in.
28. *
29. * @package DatabaseSchema
30. * @version //autogentag//
31. */
32. class ezcDbSchemaField extends ezcBaseStruct
33. {
34. /**
35. * The type of this field
36. *
37. * @var string
38. */
39. public $type ;
41. /**
42. * The length of this field.
43. *
44. * @var integer
45. */
46. public $length ;
48. /**
49. * Whether this field can store NULL values.
50. *
51. * @var bool
52. */
53. public $notNull ;
55. /**
56. * The default value for this field.
57. *
58. * @var mixed
59. */
60. public $default ;
62. /**
63. * Whether this field is an auto increment field.
64. *
65. * @var bool
66. */
67. public $autoIncrement ;
69. /**
70. * Whether the values for this field contain unsigned integers.
71. *
72. * @var bool
73. */
74. public $unsigned ;
76. /**
77. * Constructs an ezcDbSchemaField object.
78. *
79. * @param string $type
80. * @param integer $length
81. * @param bool $notNull
82. * @param mixed $default
83. * @param bool $autoIncrement
84. * @param bool $unsigned
85. */
86. function __construct ( $type, $length = false, $notNull = false, $default = null, $autoIncrement = false, $unsigned = false )
87. {
88. $this-> type = (string) $type;
89. $this-> length = (int) $length;
90. $this-> notNull = (bool) $notNull;
91. $this-> default = $default;
92. $this-> autoIncrement = (bool) $autoIncrement;
93. $this-> unsigned = (bool) $unsigned;
95. if ( $type == 'integer' && $notNull && $default === null && $autoIncrement == false )
96. {
97. $this-> default = 0;
98. }
100. if ( $type == 'integer' && is_numeric ( $this-> default ) )
101. {
102. $this-> default = (int) $this-> default ;
103. }
104. }
106. static public function __set_state ( array $array )
107. {
108. return new ezcDbSchemaField(
109. $array['type'], $array['length'], $array['notNull'],
110. $array['default'], $array['autoIncrement'], $array['unsigned']
111. );
112. }
113. }
114. ?>

Documentation generated by phpDocumentor 1.4.3