swoole / ext-postgresql

🐘 Coroutine-based client for PostgreSQL
64 stars 21 forks source link

fetchAll return false when the result is empty. #14

Open andydeng opened 4 years ago

andydeng commented 4 years ago

example:

$pg = $this->pgsqlClientDbPool->get(1); $s = $pg->query("select * from tbl_company where company_id=12312312"); //something not exist $data = $pg->fetchAll($s); // the $data variable will be false

foreach ($data as $datum) // there is a warning show up // do something

The $data variable will be FALSE, and a warning shown up in foreach statement. The code will go only if I check whether the $data is false and then give it an empty array value.

It's different behavior than most client implement.

To change this behavior is easy, change line 864 in swoole_postgresql_coro.cc file, from FAILURE to SUCCESS.

The fetchAll above will return an empty array.