catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.83k stars 1.15k forks source link

"has" method has a problem #720

Closed wendao76 closed 5 years ago

wendao76 commented 6 years ago

''' return $result === '1' || $result === true; ''' in fact, $result=1, so the method always return false

catfan commented 6 years ago

What's database and version you are using that returned $result = 1 as integer type?

ha-ni-cc commented 6 years ago

I have this problem,too.

Use mysql5.7 and medoo 1.5.4

And I setting this ,the 'has' can work well:

'option' => [ PDO::ATTR_STRINGIFY_FETCHES => true]

Convert numeric values to strings when fetching. Requires bool.

I think this is a bug because of comparing with the strict type. ''' return intval($result) === 1 || $result === true; ''' well ?

lovearthhome commented 6 years ago

@wendao76 @catfan @ha-ni-cc yes, it's a bug. now,just use "PDO::ATTR_EMULATE_PREPARES => true" to solve this.

catfan commented 5 years ago

This has been fixed on a951846f9bfe93419d40700d9fbefde5c9b10259.