| @@ 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 |
|
| @@ 192-217 (lines=26) @@ | ||
| 189 | * @return array |
|
| 190 | * @since 2.0 |
|
| 191 | */ |
|
| 192 | public function schema( $options = null ) { |
|
| 193 | ||
| 194 | $length = (int) pods_v( self::$type . '_max_length', $options, 12, true ); |
|
| 195 | ||
| 196 | if ( $length < 1 || 64 < $length ) { |
|
| 197 | $length = 64; |
|
| 198 | } |
|
| 199 | ||
| 200 | $decimals = (int) pods_v( self::$type . '_decimals', $options, 2, true ); |
|
| 201 | ||
| 202 | if ( $decimals < 1 ) { |
|
| 203 | $decimals = 0; |
|
| 204 | } |
|
| 205 | elseif ( 30 < $decimals ) { |
|
| 206 | $decimals = 30; |
|
| 207 | } |
|
| 208 | ||
| 209 | if ( $length < $decimals ) { |
|
| 210 | $decimals = $length; |
|
| 211 | } |
|
| 212 | ||
| 213 | $schema = 'DECIMAL(' . $length . ',' . $decimals . ')'; |
|
| 214 | ||
| 215 | return $schema; |
|
| 216 | ||
| 217 | } |
|
| 218 | ||
| 219 | /** |
|
| 220 | * Define the current field's preparation for sprintf |
|