DecimalType does not exist in PHPCassa?

20 views
Skip to first unread message

José Manzano

unread,
Mar 27, 2014, 4:32:48 AM3/27/14
to phpc...@googlegroups.com
Hi all, 

Well, that's my question. I have been using PHPCassa from some months ago and I have had no problems. Even I have used DecimalType for column values but when I have tried to use it for column names, it didn't work. 

Checking documentation (http://thobbs.github.io/phpcassa/api/class-phpcassa.Schema.DataType.html) I have seen this type doesn't exist. 

Does anyone know how to solve this? I have thought to modify the schema to manually add DecimalType but I'm not really sure to do it.

Thanks for your help and sorry for my English.

Tyler Hobbs

unread,
Mar 27, 2014, 10:55:50 AM3/27/14
to phpc...@googlegroups.com
No, phpcassa doesn't have support for DecimalType right now.  As far as I'm aware, there's not a standard PHP type or class for representing decimal (arbitrary precision) data.

So, you would first need to create a custom class to represent Decimal data. Then, you would create a DecimalType class with pack() and unpack() methods similar to these (but using the phcassa equivalents):
https://github.com/pycassa/pycassa/blob/master/pycassa/marshal.py#L261
https://github.com/pycassa/pycassa/blob/master/pycassa/marshal.py#L354


--
You received this message because you are subscribed to the Google Groups "phpcassa" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phpcassa+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Tyler Hobbs
DataStax

José Manzano

unread,
Mar 27, 2014, 11:41:07 AM3/27/14
to phpc...@googlegroups.com
Thanks for your help, Tyler. Probably I will try something like you recommend, but meanwhile, is there any other fast workaround? The data I'm going to store is an amount of money, in any currency so it could have 2 or 0 decimal places. 

Tyler Hobbs

unread,
Mar 27, 2014, 11:46:21 AM3/27/14
to phpc...@googlegroups.com

On Thu, Mar 27, 2014 at 10:41 AM, José Manzano <j.manzano...@gmail.com> wrote:
Thanks for your help, Tyler. Probably I will try something like you recommend, but meanwhile, is there any other fast workaround? The data I'm going to store is an amount of money, in any currency so it could have 2 or 0 decimal places. 

Just use an integer type and store the number of cents (at least, that's the term for US dollars).  For example, instead of storing 205.95, store 20595.


--
Tyler Hobbs
DataStax
Reply all
Reply to author
Forward
0 new messages