Open jedsadakorn19 opened 3 years ago
I'm new with cassandra. please give me some advice. thanks you.
The project has not been updated for a long time, and I have created a commit to fix this issue (https://github.com/cubettech/lacassa/pull/11) I assume it has not been updated because DataStax (who created the php-cassandra extension) is not supporting the Cassandra driver on PHP8; this has been taken over by Nano Interactive, as seen here: https://datastax-oss.atlassian.net/browse/PHP-239
ERROR : Declaration of Cubettech\Lacassa\Connection::table($table) must be compatible with Illuminate\Database\Connection::table($table, $as = NULL) at vendor/cubettech/lacassa/src/Connection.php:7
Connection.php :
`<?php namespace Cubettech\Lacassa;
use Illuminate\Database\Connection as BaseConnection; use Cassandra;
class Connection extends BaseConnection { /**
@var \Cassandra\DefaultSession */ protected $connection;
/**
@param array $config */
public function __construct(array $config) { $this->config = $config; // Create the connection $this->db = $config['keyspace']; $this->connection = $this->createConnection($config); $this->useDefaultPostProcessor(); }
/**
@return Query\Builder */ public function collection($collection) { $query = new Query\Builder($this); return $query->from($collection); }
/**
@return Query\Builder */ public function table($table) { return $this->collection($table); }
/**
@return [Schema\Grammar] [description] */ public function getSchemaGrammar() { return new Schema\Grammar; }
/**
@return \Cassandra\DefaultSession */ public function getCassandraConnection() { return $this->connection; }
/**
@return \Cassandra\DefaultSession */ protected function createConnection(array $config) { $cluster = Cassandra::cluster() ->withContactPoints('172.0.0.1') ->withPort(9042) ->build(); $keyspace = $config['cassandra_db']; $connection = $cluster->connect($keyspace); return $connection; }
/**
@inheritdoc */ public function disconnect() { unset($this->connection); }
/**
@inheritdoc */ public function getElapsedTime($start) { return parent::getElapsedTime($start); }
/**
@inheritdoc */ public function getDriverName() { return 'Cassandra'; }
/**
@inheritdoc */ protected function getDefaultPostProcessor() { return new Query\Processor(); }
/**
@inheritdoc */ protected function getDefaultQueryGrammar() { return new Query\Grammar(); }
/**
@inheritdoc */ protected function getDefaultSchemaGrammar() { return new Schema\Grammar(); }
/**
@return bool */ public function statement($query, $bindings = []) { foreach($bindings as $binding) { $value = 'string' == strtolower(gettype($binding)) ? "'" . $binding . "'" : $binding; $query = preg_replace('/\?/', $value, $query, 1); } $builder = new Query\Builder($this, $this->getPostProcessor()); return $builder->executeCql($query); }
/**
@return int */ public function affectingStatement($query, $bindings = []) { // For update or delete statements, we want to get the number of rows affected // by the statement and return that back to the developer. We'll first need // to execute the statement and then we'll use PDO to fetch the affected. foreach($bindings as $binding) { $value = $value = 'string' == strtolower(gettype($binding)) ? "'" . $binding . "'" : $binding; $query = preg_replace('/\?/', $value, $query, 1); } $builder = new Query\Builder($this, $this->getPostProcessor());
}
/**
@return bool */ public function raw($query) { $builder = new Query\Builder($this, $this->getPostProcessor()); $result = $builder->executeCql($query); return $result; }
/**