@@ 215-240 (lines=26) @@ | ||
212 | * @return array |
|
213 | * @since 2.0 |
|
214 | */ |
|
215 | public function schema( $options = null ) { |
|
216 | ||
217 | $length = (int) pods_v( self::$type . '_max_length', $options, 12, true ); |
|
218 | ||
219 | if ( $length < 1 || 64 < $length ) { |
|
220 | $length = 64; |
|
221 | } |
|
222 | ||
223 | $decimals = (int) pods_v( self::$type . '_decimals', $options, 2, true ); |
|
224 | ||
225 | if ( $decimals < 1 ) { |
|
226 | $decimals = 0; |
|
227 | } |
|
228 | elseif ( 30 < $decimals ) { |
|
229 | $decimals = 30; |
|
230 | } |
|
231 | ||
232 | if ( $length < $decimals ) { |
|
233 | $decimals = $length; |
|
234 | } |
|
235 | ||
236 | $schema = 'DECIMAL(' . $length . ',' . $decimals . ')'; |
|
237 | ||
238 | return $schema; |
|
239 | ||
240 | } |
|
241 | ||
242 | /** |
|
243 | * Define the current field's preparation for sprintf |
@@ 140-159 (lines=20) @@ | ||
137 | * @return array |
|
138 | * @since 2.0 |
|
139 | */ |
|
140 | public function schema ( $options = null ) { |
|
141 | $length = (int) pods_var( self::$type . '_max_length', $options, 12, null, true ); |
|
142 | ||
143 | if ( $length < 1 || 64 < $length ) |
|
144 | $length = 64; |
|
145 | ||
146 | $decimals = (int) pods_var( self::$type . '_decimals', $options, 0, null, true ); |
|
147 | ||
148 | if ( $decimals < 1 ) |
|
149 | $decimals = 0; |
|
150 | elseif ( 30 < $decimals ) |
|
151 | $decimals = 30; |
|
152 | ||
153 | if ( $length < $decimals ) |
|
154 | $decimals = $length; |
|
155 | ||
156 | $schema = 'DECIMAL(' . $length . ',' . $decimals . ')'; |
|
157 | ||
158 | return $schema; |
|
159 | } |
|
160 | ||
161 | /** |
|
162 | * Define the current field's preparation for sprintf |