I have a problem with a new MariaDB 10.5.8 install. STRICT_TRANS_TABLES is set, and when I try to use $sql of:
'INSERT INTO test (flag) VALUES (?)'
(where flag is defined as tinyint(1)) with var_dump($params) showing as:
array(1) {
[0]=>
bool(false)
}
I get this message:
Incorrect integer value: '' for column `mydb`.`test`.`flag` at row 1
If, instead, I do:
'INSERT INTO test (flag) VALUES (false)'
with no parameters, it works as expected.
This is how I connect to the database:
$this->PDO = new PDO('mysql:host=' . DB_SERVER . ';dbname=' . DB_NAME . ';charset=utf8mb4', DB_USER, DB_PASSWORD, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_STRINGIFY_FETCHES => false,
]);
$this->PDO->query("SET NAMES 'utf8mb4' COLLATE 'utf8mb4_unicode_ci'");
and this is how I send the query/params to MariaDB:
$stmt = self::$_instance->PDO->prepare($sql);
$stmt->execute($params);
If I try to insert true instead of false, everything works fine. true is being converted to 1 somewhere along the lines, and false to ''. What am I doing wrong?