php-cassandra-binary icon indicating copy to clipboard operation
php-cassandra-binary copied to clipboard

Blob data received correctly

Open gonzalophp opened this issue 10 years ago • 4 comments

Check this changes for blob columns.

gonzalophp avatar Jul 27 '14 14:07 gonzalophp

Sorry, how do you make a request to the database? What is now working perfectly. What exactly do you save as blob into blob column?

evseevnn-zz avatar Jul 27 '14 15:07 evseevnn-zz

A normal query ( select * from keyspace.columnfamily) to a column family with blob columns. The data is displayed as 0x binary strings when running from cqlsh command line.

The same query from this library was producing an error (more length than data available)

gonzalophp avatar Jul 27 '14 17:07 gonzalophp

How do I check.

$database = new Database(['127.0.0.1'], 'for_tests');
$database->connect();
//$database->query('DROP TABLE "tests";');
$database->query('CREATE TABLE "tests" (
    id int PRIMARY KEY,
    "blobData" blob
);');
$database->query(
    'INSERT INTO "tests" (id, "blobData") VALUES
                        (:id, :blob)', [
    'id' => 1,
    'blob' => 3
]);
$result = $database->query('SELECT "blobData" FROM "tests" WHERE "id" = 1;');

This returns me to '3'. :tada:
At the same time, if you make a query using cqlsh, the value will be: 0x0000000133

As far as I understand, all right. Purpose - to provide data on their value is not in hex.

Am I wrong :question:

evseevnn-zz avatar Jul 28 '14 19:07 evseevnn-zz

What happens when you run that query after going to cqlsh with something like this?

insert into tests (id, "blobData") values (2, 0x03);

gonzalophp avatar Jul 28 '14 21:07 gonzalophp