I think, therefore I am. I am, therefore I sail

Running comparisons on Windows Azure Storage for PHP developers

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…


Converting DateTime.Ticks to a Unix timestamp and back in PHP


Floating by Hugo Leckey

1 Comment

  1. Your blog is very nice… Thanks for sharing your information…

Leave a Reply

Your email address will not be published. Required fields are marked *

Powered by WordPress & Beards