PHP-MySQLi-Database-Class icon indicating copy to clipboard operation
PHP-MySQLi-Database-Class copied to clipboard

setQueryOption for Update Method

Open darkcavalry opened this issue 6 years ago • 0 comments

Hello,

I have two tables as groups and members named. member e-mail addresses has unique index with group_id and member_mail. (same e-mails can be stored on different groups)

When I try to merge all groups into new group it gives duplicated entry for duplicated e-mail and group id reason.

So, I was tried

$db->setQueryOption('IGNORE')->where('group_id=1 OR group_id=3')->update('members',['group_id'=>5]);

executed query returns

UPDATE members SET 'group_id' = '5' WHERE group_id='1' OR group_id='3'

There no query keyword included on update method.

I've changed Line 907 of MysqliDb.php

$this->_query = "UPDATE " . self::$prefix . $tableName;

to

$this->_query = "UPDATE " . implode(' ', $this->_queryOptions) . " " . self::$prefix . $tableName;

its works fine now. Is this bug or am I using setQueryOption incorrectly?

darkcavalry avatar Feb 09 '20 16:02 darkcavalry