0

i'm currently working with MemSQL Columnstore and trying to integrate it with laravel 5, but everytime i tried to make a query I got the following error

SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll().

I've been searching and found this:

Don't use prepared statements in Laravel Eloquent ORM?

And tried to do it like so but is not working. Here's my query

 public function index(){
    $sql = 'SELECT * FROM SCORE LIMIT 20';
    $pdo = DB::getPdo();
    $query = $pdo->query($sql);
    $result = $query->fetchAll();

    return view('home', compact('result'));
}

Any guidance would be highly appreciated.

1 Answers1

0

I had this same issue as well.

According to the MemSQL documentation, you need to configure the client driver: https://docs.memsql.com/concepts/v6.0/prepared-statements/

In database.php, add in a new options key.

Here's my configuration, it's pretty much the same as the default, notice the options key.

'mysql' => [
    'driver' => 'mysql',
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', 'forge'),
    'username' => env('DB_USERNAME', 'forge'),
    'password' => env('DB_PASSWORD', ''),
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix' => '',
    'strict' => true,
    'engine' => null,
    'options' => array(
        PDO::ATTR_EMULATE_PREPARES => TRUE
    ),
],
PaulM
  • 3,281
  • 3
  • 28
  • 38