| @@ 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 |
|
| @@ 214-239 (lines=26) @@ | ||
| 211 | * @return array |
|
| 212 | * @since 2.0 |
|
| 213 | */ |
|
| 214 | public function schema( $options = null ) { |
|
| 215 | ||
| 216 | $length = (int) pods_v( self::$type . '_max_length', $options, 12, true ); |
|
| 217 | ||
| 218 | if ( $length < 1 || 64 < $length ) { |
|
| 219 | $length = 64; |
|
| 220 | } |
|
| 221 | ||
| 222 | $decimals = (int) pods_v( self::$type . '_decimals', $options, 2, true ); |
|
| 223 | ||
| 224 | if ( $decimals < 1 ) { |
|
| 225 | $decimals = 0; |
|
| 226 | } |
|
| 227 | elseif ( 30 < $decimals ) { |
|
| 228 | $decimals = 30; |
|
| 229 | } |
|
| 230 | ||
| 231 | if ( $length < $decimals ) { |
|
| 232 | $decimals = $length; |
|
| 233 | } |
|
| 234 | ||
| 235 | $schema = 'DECIMAL(' . $length . ',' . $decimals . ')'; |
|
| 236 | ||
| 237 | return $schema; |
|
| 238 | ||
| 239 | } |
|
| 240 | ||
| 241 | /** |
|
| 242 | * Define the current field's preparation for sprintf |
|