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

rawQueryValue returning unexpected array

Open teocns opened this issue 5 years ago • 1 comments

Hello, I have been using this library for years. Exceptional! Today I was debugging some code and I managed to reproduce something that IMO shouldn't happen:

$myId = Db::instance()->rawQueryValue( 'select id from users where users.id = ? limit 1 ', [ 262 ] ); die(print_r($myId));

Guess what this outputs.... An array! Whilst it should output a single value, shouldn't it?

Array ( [0] => 262 ) 1

EDIT: I found out that the issue is adding a space, or a backspace after "limit 1" at the end of the query. I think this can be fixed with an rtrim() image

teocns avatar Mar 30 '20 17:03 teocns

Hmm. Right. Regex wasn't parsing it. Send a PR ?

https://github.com/ThingEngineer/PHP-MySQLi-Database-Class/blob/9a95f2488495f13494e7c19ba7ad452946e947a7/MysqliDb.php#L620

harryqt avatar Apr 08 '20 23:04 harryqt