Skip to content

Prepared statements #4

@telemmaite

Description

@telemmaite

It looks like I get it working only with
PDO::ATTR_EMULATE_PREPARES => true
If the attribute is set to false , nothing is captured.

I try with a very simple script

<?php
$host = '0.0.0.0';
$db   = 'xxx';
$user = 'xxx';
$pass = 'xxx';
$port = 3303;
$charset = 'utf8';

$dsn = "mysql:host=$host;dbname=$db;charset=$charset;port=$port";
$options = [
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    PDO::ATTR_EMULATE_PREPARES   => false,// does not work if set to true it works
];
try {
     $pdo = new PDO($dsn, $user, $pass, $options);
     $stmt = $pdo->query('SELECT NOW()');
     while ($row = $stmt->fetch()){
         var_dump($row);
     }
} catch (\PDOException $e) {
     throw new \PDOException($e->getMessage(), (int)$e->getCode());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions