diff --git a/README.md b/README.md index cb8bbb5..9489c14 100644 --- a/README.md +++ b/README.md @@ -118,17 +118,21 @@ $rows = $response->fetchAll(); ```php $batchRequest = new Cassandra\Request\Batch(); -$batchRequest->appendQueryId($preparedData['id'], $strictValues) - ->appendQuery( - 'INSERT INTO "students" ("id", "name", "age") VALUES (:id, :name, :age)', - [ - 'id' => new Cassandra\Type\Uuid('c5420d81-499e-4c9c-ac0c-fa6ba3ebc2bc'), - 'name' => new Cassandra\Type\Varchar('Mark'), - 'age' => 20, - ] - ); - -$response = $connection->syncRequest($batch); + +// Append a prepared query +$batchRequest->appendQueryId($preparedData['id'], $strictValues); + +// Append a query string +$batchRequest->appendQuery( + 'INSERT INTO "students" ("id", "name", "age") VALUES (:id, :name, :age)', + [ + 'id' => new Cassandra\Type\Uuid('c5420d81-499e-4c9c-ac0c-fa6ba3ebc2bc'), + 'name' => new Cassandra\Type\Varchar('Mark'), + 'age' => 20, + ] +); + +$response = $connection->syncRequest($batchRequest); $rows = $response->fetchAll(); ``` diff --git a/src/Request/Batch.php b/src/Request/Batch.php index 2c944f9..8e00c12 100644 --- a/src/Request/Batch.php +++ b/src/Request/Batch.php @@ -40,7 +40,7 @@ class Batch extends Request{ * @param array $options */ public function __construct($type = null, $consistency = null, $options = []) { - $this->_batchType = $type ?: Batch::TYPE_LOGGED; + $this->_batchType = $type === null ? Batch::TYPE_LOGGED : $type; $this->_consistency = $consistency === null ? Request::CONSISTENCY_QUORUM : $consistency; $this->_options = $options; } diff --git a/src/Response/Result.php b/src/Response/Result.php index 4815b9c..6a33e5e 100644 --- a/src/Response/Result.php +++ b/src/Response/Result.php @@ -326,7 +326,7 @@ public function fetchCol($index = 0){ $array = new \SplFixedArray($rowCount); for($i = 0; $i < $rowCount; ++$i){ - foreach($columns as $j => $column){ + foreach($this->_metadata['columns'] as $j => $column){ $value = $this->_readBytesAndConvertToType($column['type']); if ($j == $index)