PHP code example of codelieutenant / scylla-driver
1. Go to this page and download the library: Download codelieutenant/scylla-driver library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
codelieutenant / scylla-driver example snippets
$session = Cassandra::cluster()
->withContactPoints('127.0.0.1')
->withPort(9042)
->withCredentials('cassandra', 'cassandra')
->withTokenAwareRouting(true)
->build()
->connect('my_keyspace');
// Simple string query
$session->execute("INSERT INTO users (id, name) VALUES (uuid(), 'Alice')");
// Prepared statement with bound values
$prepared = $session->prepare('SELECT * FROM users WHERE id = ?');
$result = $session->execute($prepared, ['arguments' => [$id]]);
foreach ($result as $row) {
printf("User: %s\n", $row['name']);
}