Re: cvs: php4 /ext/pgsql pgsql.c
| From: | Yasuo Ohgaki | Date: | Sat, 24 Aug 2002 23:32:03 +0000 |
| Subject: | Re: cvs: php4 /ext/pgsql pgsql.c | ||
| References: | 1 2 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-13650@lists.php.net to get a copy of this message | ||
derick@php.net wrote:
On Sat, 24 Aug 2002, Yasuo Ohgaki wrote:I usually write code as follows $result = pg_get_result($db); if (!is_resource($result)) { // error return FALSE; } if (($error = pg_get_result($db)) { // error return FALSE; } // do something useful A person mentioned we can write $result = pg_get_result($db); if (($error = pg_get_result($db)) { // error return FALSE; } if these functions do not raise E_WARNING. These functions takes resource as parameter and functions returns resource may return FALSE when there is error, resulting E_WARNING since parameter expected is resource, but bool is passed. (I know we can use @, but error event causes problem with user defiend error handlers if error is raised.) We can simpliy script a bit with this change. IMO, it's a little easier to read and it does not hide bugs badly. Users will catch script bugs when they get resource almost always, so we can safely remove error message. Although, I cannot think of case this change hide script bugs badly, I'm willing to revert this if this hide bugs. Any comments? -- Yasuo Ohgakiyohgaki Sat Aug 24 18:28:28 2002 EDTWhy would you want that? DerickModified files: /php4/ext/pgsql pgsql.c Log: Changed pg_connection_info()/pg_connection_reset()/pg_connection_busy()/pg_result_status()/pg_result_error() silently return FALSE when resource is not passed to them. @ Changed pg_connection_info()/pg_connection_reset()/pg_connection_busy()/pg_result_status()/pg_result_error() silently return FALSE when resource is not passed to them. (Yasuo)