1@cassandra-version-2.1 2Feature: Tuples 3 4 PHP Driver supports Cassandra tuples 5 6 Background: 7 Given a running Cassandra cluster 8 9 Scenario: Using Cassandra tuples 10 Given the following schema: 11 """cql 12 CREATE KEYSPACE simplex WITH replication = { 13 'class': 'SimpleStrategy', 14 'replication_factor': 1 15 }; 16 USE simplex; 17 CREATE TABLE users ( 18 id uuid PRIMARY KEY, 19 name text, 20 address tuple<text, text, int> 21 ); 22 """ 23 And the following example: 24 """php 25 <?php 26 $cluster = Cassandra::cluster()->build(); 27 $session = $cluster->connect("simplex"); 28 29 $tupleType = Cassandra\Type::tuple(Cassandra\Type::text(), Cassandra\Type::text(), Cassandra\Type::int()); 30 31 $users = array( 32 array( 33 new Cassandra\Uuid('56357d2b-4586-433c-ad24-afa9918bc415'), 34 'Charles Wallace', 35 $tupleType->create('Phoenix', '9042 Cassandra Lane', 85023) 36 ), 37 array( 38 new Cassandra\Uuid('ce359590-8528-4682-a9f3-add53fc9aa09'), 39 'Kevin Malone', 40 $tupleType->create('New York', '1000 Database Road', 10025) 41 ), 42 array( 43 new Cassandra\Uuid('7d64dca1-dd4d-4f3c-bec4-6a88fa082a13'), 44 'Michael Scott', 45 $tupleType->create('Santa Clara', '20000 Log Ave', 95054) 46 ) 47 ); 48 49 foreach ($users as $user) { 50 $options = array('arguments' => $user); 51 $session->execute("INSERT INTO users (id, name, address) VALUES (?, ?, ?)", $options); 52 } 53 54 $result = $session->execute("SELECT * FROM users"); 55 56 foreach ($result as $row) { 57 echo "ID: {$row['id']}" . PHP_EOL; 58 echo "Name: {$row['name']}" . PHP_EOL; 59 echo "Address:" . PHP_EOL; 60 foreach ($row['address'] as $format) { 61 echo " {$format}" . PHP_EOL; 62 } 63 } 64 """ 65 When it is executed 66 Then its output should contain: 67 """ 68 ID: 56357d2b-4586-433c-ad24-afa9918bc415 69 Name: Charles Wallace 70 Address: 71 Phoenix 72 9042 Cassandra Lane 73 85023 74 ID: ce359590-8528-4682-a9f3-add53fc9aa09 75 Name: Kevin Malone 76 Address: 77 New York 78 1000 Database Road 79 10025 80 ID: 7d64dca1-dd4d-4f3c-bec4-6a88fa082a13 81 Name: Michael Scott 82 Address: 83 Santa Clara 84 20000 Log Ave 85 95054 86 """ 87