php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48189 ibase_execute error in return param
Submitted: 2009-05-08 09:19 UTC Modified: 2009-07-25 23:40 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:0 (0.0%)
From: maxwer at ukr dot net Assigned: kalle (profile)
Status: Closed Package: InterBase related
PHP Version: 5.2.9 OS: Win2000SP4
Private report: No CVE-ID: None
 [2009-05-08 09:19 UTC] maxwer at ukr dot net
Description:
------------
ibase_execute return values

http://ua2.php.net/manual/ru/function.ibase-execute.php
?????????: In PHP 5.0.0 and up, this function returns the number of rows affected by the query (if > 0 and applicable to the statement type). A query that succeeded, but did not affect any rows (e.g. an UPDATE of a non-existent record) will return TRUE. 

 if(Affected_rows == 0){
   return STRING "0 " (zero and space) THIS ERROR! need BOOLEAN true
 }else{
   return INTEGER n   --- this normal
 }



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-11 16:15 UTC] felipe@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2009-05-19 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-05-20 11:37 UTC] max_wer at ukr dot net
echo "<PRE>";
$b = ibase_connect('127.0.0.1:employee','SYSDBA',SYSDBA_PASS);
$t = ibase_trans(IBASE_WRITE);
// update 0 rows
$p = ibase_prepare($b,'update rdb$database set RDB$DESCRIPTION = null where RDB$DESCRIPTION = \'false_condition\'');
$r = ibase_execute($p);
ibase_rollback($t);
var_dump($r); // string(2) "0 ","0 " ? but need bool(true)
 [2009-06-08 12:32 UTC] lester at lsces dot co dot uk
I've got this configured on my test machine now, and con confirm that the if there is an error then false is returned, but a functional query which affects no rows returns '0' as would probably be expected in other Firebird Applications?
The question is - should the documentation be changed or the function extended?
ibase_query has the same problem!
 [2009-06-18 12:15 UTC] max_wer at ukr dot net
A function returns the line of '0 '(with space),
 if it will return a number 0,
 I will be happy :-)
 [2009-06-18 12:17 UTC] max_wer at ukr dot net
I beg pardon.
A function returns the STRING '0 ',
if it will return and INTEGER 0,
I will be happy
 [2009-07-15 14:06 UTC] lf dot amorim at yahoo dot com dot br
I am also encountering the same problem.
 [2009-07-22 08:23 UTC] kalle@php.net
Could you please try with this patch against PHP_5_3 svn:
Index: ibase_query.c
===================================================================
--- ibase_query.c	(revision 284410)
+++ ibase_query.c	(working copy)
@@ -1031,8 +1031,7 @@
 				if (affected_rows) {
 					RETVAL_LONG(affected_rows);
 				} else {
-					/* this return value evaluates to bool(true) and to int(0) */
-					RETVAL_STRINGL("0 ",2,1);
+					RETVAL_TRUE;
 				}
 				break;
 			}

 [2009-07-25 02:57 UTC] felipe@php.net
The patch is fine, Kalle. (Not for 5.2.x though)
But we need to warn in the documentation about someone relying in the 'if (ibase_execute())' check. As the function is intended to return FALSE on error, and the "0 " has been used until the moment to be an "zero true".

 [2009-07-25 23:37 UTC] svn@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=286330
Log: Fixed bug #48189 (ibase_execute error in return param)
 [2009-07-25 23:39 UTC] svn@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=286331
Log: MFB: Fixed bug #48189 (ibase_execute error in return param)
 [2009-07-25 23:40 UTC] svn@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=286332
Log: BFN #48189
 [2009-07-25 23:40 UTC] kalle@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Fixed in 5.3.1
 [2009-07-25 23:46 UTC] svn@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=286334
Log: Changelog for bug #48189
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 03:01:29 2024 UTC