easydb icon indicating copy to clipboard operation
easydb copied to clipboard

Some bug when filter data by column type bit(1)

Open RuslanMelnychenko opened this issue 2 years ago • 0 comments

When filter some data where type of column bit(1) (like true, false) and filter true then request return nothing.

$db->run("SELECT t2.`comment_id` AS `comment_id`, 
t2.`text` AS `text`, 
BIT_COUNT(t2.`public`) AS `public`, 
t2.`updated` AS `updated`, 
t2.`created` AS `created`, 
BIT_COUNT(t2.`archived`) AS `archived`
FROM `tasks_comments` AS t2
WHERE t2.`task_id` = ? AND (t2.`public` = ?)
ORDER BY t2.`comment_id` ASC", 24408, true);

But when make request without include value of filter in function, request return correct data

$db->run("SELECT t2.`comment_id` AS `comment_id`, 
t2.`text` AS `text`, 
BIT_COUNT(t2.`public`) AS `public`, 
t2.`updated` AS `updated`, 
t2.`created` AS `created`, 
BIT_COUNT(t2.`archived`) AS `archived`
FROM `tasks_comments` AS t2
WHERE t2.`task_id` = ? AND (t2.`public` = 1)
ORDER BY t2.`comment_id` ASC", 24408);

How I understand, it's bug because All values are treated as PDO::PARAM_STR.

When set filter false, it works current. But with true incorrect. How can fix it? When need to use as argument in function?

PHP 7.4. MySQL 8.0

RuslanMelnychenko avatar Aug 25 '22 13:08 RuslanMelnychenko