Running comparisons on Windows Azure Storage for PHP developers

By , March 16, 2011 3:02 pm

Let me setup a scenario. You have a Windows Azure Storage Table with a column called PartitionKey that is a series of numbers that are timestamps. You are testing your code to retrieve all timestamps greater than X in order to perform time based data calculations. Being smart you try “PartitionKey gt 1”, because 065983400000 is greater than 1 right? WRONG! Haha sucka! 065983400000 is not a number, it’s a string! Now being that I am a PHP programmer I do not even think about data types because PHP takes care of it for me in 99% of cases, so I was befuddled. Take a look again and you will see that a string comparison is happening, which means 065983400000 is in fact smaller than 1 because the string starts with a 0 which is less in value than a 1. If you had done 01 it would have worked because string comparisons start left and move right so you get: 0=0 next, 1 < 6, etc.

Be sure you keep this in mind when developing for Windows Azure Storage in PHP. Data types mean something in those other languages…

Leave a Reply

Theme by Blam Designs
Based on Themocracy

Add this ribbon to your WordPress website re-abolish slavery
%d bloggers like this: