Created
June 30, 2016 15:52
-
-
Save mpenick/9a8f3e0d1e5aaa2a178fca9cc22608e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $cluster = Cassandra::cluster()->build(); | |
| $session = $cluster->connect(); | |
| $session->execute(new Cassandra\SimpleStatement( | |
| "CREATE KEYSPACE IF NOT EXISTS test WITH replication = | |
| {'class': 'SimpleStrategy', 'replication_factor': '3'} AND durable_writes = true;") | |
| ); | |
| $session->execute(new Cassandra\SimpleStatement( | |
| "CREATE TABLE IF NOT EXISTS test.test_table ( | |
| test_id int PRIMARY KEY, | |
| test_active boolean, | |
| test_age set<text>, | |
| test_gender set<text>, | |
| test_int_set set<int>, | |
| test_int int, | |
| test_set set<int> | |
| ) WITH bloom_filter_fp_chance = 0.01 | |
| AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} | |
| AND comment = '' | |
| AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} | |
| AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} | |
| AND crc_check_chance = 1.0 | |
| AND dclocal_read_repair_chance = 0.1 | |
| AND default_time_to_live = 0 | |
| AND gc_grace_seconds = 864000 | |
| AND max_index_interval = 2048 | |
| AND memtable_flush_period_in_ms = 0 | |
| AND min_index_interval = 128 | |
| AND read_repair_chance = 0.0 | |
| AND speculative_retry = '99PERCENTILE'; | |
| ")); | |
| $keyspace = 'test'; | |
| $source = 'test_table'; | |
| $set ="test_active = null, test_age = null, test_gender = null, test_int_set = null, test_int = 100500, test_set = null "; | |
| $where = "test_id = 100500;"; | |
| $session->execute( | |
| new \Cassandra\SimpleStatement("UPDATE $keyspace.$source SET $set WHERE $where"), | |
| new \Cassandra\ExecutionOptions([ | |
| 'consistency' => \Cassandra::CONSISTENCY_ALL | |
| ])); | |
| $rows = $session->execute( | |
| new \Cassandra\SimpleStatement("SELECT * FROM $keyspace.$source"), | |
| new \Cassandra\ExecutionOptions([ | |
| 'consistency' => \Cassandra::CONSISTENCY_ALL | |
| ])); | |
| foreach ($rows as $row) { | |
| var_dump($row); | |
| } | |
| $set ="test_active=True,test_age={'18-25'},test_gender={'m'}, test_int_set = null, test_int = 100500, test_set= null"; | |
| $where = "test_id = 100500;"; | |
| $session->execute( | |
| new \Cassandra\SimpleStatement("UPDATE $keyspace.$source SET $set WHERE $where"), | |
| new \Cassandra\ExecutionOptions([ | |
| 'consistency' => \Cassandra::CONSISTENCY_ALL | |
| ])); | |
| $rows = $session->execute( | |
| new \Cassandra\SimpleStatement("SELECT * FROM $keyspace.$source"), | |
| new \Cassandra\ExecutionOptions([ | |
| 'consistency' => \Cassandra::CONSISTENCY_ALL | |
| ])); | |
| foreach ($rows as $row) { | |
| var_dump($row); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment