From fd5a9454291e3847fdd66056c029330e0f115f76 Mon Sep 17 00:00:00 2001 From: shen2 Date: Mon, 29 Sep 2014 16:11:24 +0800 Subject: [PATCH] implement README.md --- README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9489c14..5f470e2 100644 --- a/README.md +++ b/README.md @@ -5,17 +5,17 @@ Cassandra client library for PHP -Cassandra client library for PHP, which support Protocol v3 and asynchronous request +Cassandra client library for PHP, which support Protocol v3 (Cassandra 2.1) and asynchronous request ## Features -* Using Protocol v3 +* Using Protocol v3 (Cassandra 2.1) * Support asynchronous and synchronous request * Support for logged, unlogged and counter batches * The ability to specify the consistency, "serial consistency" and all flags defined in the protocol * Support Query preparation and execute * Support all data types convertion and binding * Support conditional update/insert -* 4 fetch methods (fetchAll, fetchRow, fetchCol, fetchOne) +* 5 fetch methods (fetchAll, fetchRow, fetchPairs, fetchCol, fetchOne) * 800% performance improvement(async mode) than other php cassandra client libraries ## Installation @@ -68,6 +68,9 @@ $rows = $response->fetchAll(); // SplFixedArray // Return a SplFixedArray containing a specified index column from the result set. $col = $response->fetchCol(); // SplFixedArray +// Return a assoc array with key-value pairs, the key is the first column, the value is the second column. +$col = $response->fetchPairs(); // assoc array + // Return the first row of the result set. $row = $response->fetchRow(); // ArrayObject @@ -120,7 +123,11 @@ $rows = $response->fetchAll(); $batchRequest = new Cassandra\Request\Batch(); // Append a prepared query -$batchRequest->appendQueryId($preparedData['id'], $strictValues); +$preparedData = $connection->prepare('SELECT * FROM "users" WHERE "id" = :id'); +$values = [ + 'id' => 'c5420d81-499e-4c9c-ac0c-fa6ba3ebc2bc', + ]; +$batchRequest->appendQueryId($preparedData['id'], Cassandra\Request\Request::strictTypeValues($values, $preparedData['metadata']['columns'])); // Append a query string $batchRequest->appendQuery( @@ -180,8 +187,8 @@ All types are supported. // CollectionSet new Cassandra\Type\CollectionSet([1, 2, 3], Cassandra\Type\Base::INT); -// Timestamp - new Cassandra\Type\Timestamp(1409830696263); +// Timestamp (unit: microseconds) + new Cassandra\Type\Timestamp(1409830696263000); // Uuid new Cassandra\Type\Uuid('62c36092-82a1-3a00-93d1-46196ee77204');