mercredi 16 novembre 2016

Cassandra DB connection on Laravel controller

I've tried this suggestion over at laracasts but it still won't let my laravel connect to cassandra.

What I'm doing is put the sample code from http://ift.tt/2f0LCTI, put it on my controller, and modify the cql statement. The raw php works but when I put it on my controller it throws an error.

The error I'm facing is:

Undefined property: Cassandra\Cluster\Builder::$build

Code that I used:

<?php
$cluster   = Cassandra::cluster()->withContactPoints('172.17.0.2')->build();
$keyspace  = 'testspace';
$session   = $cluster->connect($keyspace);
$statement = new Cassandra\SimpleStatement(
    'SELECT * FROM users'
);
$future    = $session->executeAsync($statement);
$result    = $future->get();

echo "Connected to <b>" . $keyspace . "</b> keyspace <br><br>";

foreach ($result as $row) {
    printf("The id number <b>%s</b> belongs to <b>%s %s</b>. <br>", $row['user_$
}

I'm guessing laravel is still trying to know where should it look for those functions even though they're php extensions.

Laravel version: 5.3
Cassandra version: 3.9



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire