git clone https://github.com/datastax/cpp-driver.git
cd cpp-driver cmake . && make && make install
ln -s libcql.so.0.7.0 /usr/lib/libcql.so.0 ln -s /usr/lib/libcql.so.0 /usr/lib/libcql.so
git clone https://github.com/aparkhomenko/php-cassandra.git cd php-cassandra phpize && ./configure && make
php -d="extension=modules/cassandra.so" -m
// Suppose you have the Cassandra cluster at 127.0.0.1, // listening at default port (9042). $builder = new CqlBuilder(); $builder->addContactPoint("127.0.0.1"); // Now build a model of cluster and connect it to DB. $cluster = $builder->build(); $session = $cluster->connect(); // Write a query, switch keyspaces. $query = new CqlQuery('SELECT * FROM system.schema_keyspaces'); // Send the query. $future = $session->query($query); // Wait for the query to execute; retrieve the result. $future->wait(); $result = $future->getResult(); if (null === $future->getError()) { echo "rowCount: {$result->getRowCount()}\n"; while ($result->next()) { echo "strategy_options: " . $result->get("strategy_options") . "\n"; } } // Boilerplate: close the connection session and perform the cleanup. $session->close(); $cluster->shutdown();
Source: https://habr.com/ru/post/221521/
All Articles