• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Is it possible to specify TYPE_UDECIMAL

Sadik B

Well-known member
#1
I am creating a custom DataWriter for an addon I am making and I need that one of the fields in the table in which I hold decimal values. My field is defined as DECIMAL(10,2) in mysql table. So in the _getFields() function can I use 'type' => self::TYPE_UDECIMAL(10,2)

I am guessing not. So what's the best way of writing fixed precision data (not floating point numbers) to the database through a datawriter?
 

Jake Bunce

XenForo moderator
Staff member
#2
That is not one of the available types (XenForo_DataWriter).

http://help.scibit.com/mascon/masconMySQL_Field_Types.html

DECIMAL,
NUMERIC

An unpacked floating-point number. Cannot be unsigned

Behaves like a CHAR column: “unpacked” means the number is stored as a string, using one character for each digit of the value. The decimal point, and, for negative numbers, the ‘-‘ sign is not counted in Length. If Decimals is 0, values will have no decimal point or fractional part. The maximum range of DECIMAL values is the same as for DOUBLE, but the actual range for a given DECIMAL column may be constrained by the choice of Length and Decimals. If Decimals is left out it’s set to 0. If Length is left out it’s set to 10. Note that in MySQL 3.22 the Length includes the sign and the decimal point
Since it is stored as a string perhaps you can use a string type.