CHItA wrote: Thu Jan 14, 2021 9:19 am
That is incorrect.
Indeed, but just the part that Doctrine DBAL was built on top of PDO.
I've been using that for years and just found out that's not true
🤦♂️
So, to use named parameters on MySQL it just need to use the
pdo_mysql
driver.
Code: Select all
<?php
require_once __DIR__ . '/vendor/autoload.php';
$conn = Doctrine\DBAL\DriverManager::getConnection([
'driver' => 'pdo_mysql',
'host' => 'localhost',
'port' => 3306,
'user' => 'notroot',
'password' => 'asupersecurepassword'
]);
$sql = 'SELECT ENGINE, TABLE_ROWS, VERSION() FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = :table_name AND TABLE_SCHEMA = :database_name';
$stmt = $conn->prepare($sql);
$stmt->bindValue(':table_name', 'phpbb_posts');
$stmt->bindValue(':database_name', 'dev_phpbb');
$stmt->execute();
$result = $stmt->fetch();
echo '<pre><code>';
var_dump($result);
echo '</code></pre>';