duoshuo/php-cassandra — pull request #11 by sebastiankalwa (2014-11-27 15:56:56+00:00)
Title: fix for CollectionMap if array key is numeric

CollectionMap assumed that the array key is always a string. Let's create following table:

CREATE TABLE IF NOT EXISTS test_table (
id_column int primary key,
map_column map
);

The query "UPDATE test SET map_column = ? WHERE id_column = ?" with the map_column value "new CollectionMap(['123' => 123], Base::TEXT, Base::INT)" fails because CollectionMap.php passes the int 123 to Base::getTypeObject which passes it to the Varchar class. The Varchar class throws following exception because is_string($value) is false:

PHP Fatal error: Method Cassandra\Request\Query::__toString() must not throw an exception in /var/www/cassandra/vendor/duoshuo/php-cassandra/src/Connection.php on line 0

I typecasted the array key to string to catch this case.