ThingEngineer / PHP-MySQLi-Database-Class

Wrapper for a PHP MySQL class, which utilizes MySQLi and prepared statements.
Other
3.29k stars 1.35k forks source link

rawQueryValue returning unexpected array #894

Open teocns opened 4 years ago

teocns commented 4 years ago

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

harryqt commented 4 years ago

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

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