php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #31592 ext/informix: ifx_getsqlca fails when DB-error occurs
Submitted: 2005-01-18 09:26 UTC Modified: 2009-05-04 15:10 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: andreybl at matrix dot co dot il Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.0.4, 4.3.11 OS: RedHat 3.0 ES
Private report: No CVE-ID: None
 [2005-01-18 09:26 UTC] andreybl at matrix dot co dot il
Description:
------------
In case when ifx_query() fails it returns FALSE as result id.
When ifx_getsqlca gets false as result id, it complains:
<b>Warning</b>:  ifx_getsqlca(): supplied resource is not a valid Informix Result resource in <b>

This is actually a BUG, since when the sql-query fails, it is stll neccessary sometimes, to get the sqlca structure. E.g. to get the ISAM error.

Reproduce code:
---------------
    sleep(20);
    $db->begin_transaction();
    $sql = "update tb set recordingdate = '2005-01-12 11:33:57.597' where id = 138";
    
    if (!($resid = ifx_query($sql, $db->connid)))
    {
        echo "Failed to open:\n$sql\n".ifx_error()."\n";
        $db->rollback_transaction();
        $sqlca = ifx_getsqlca($resind);
        var_dump($sqlca);
        die();
    }
    else 
    {
        echo "Open successfull\n";
        ifx_free_result($resid);
        $db->commit_transaction();
    }

Expected result:
----------------
ifx_getsqlca should get me the sqlca structure and not an error.

Actual result:
--------------
ifx_getsqlca fails, the following message appears:
<b>Warning</b>:  ifx_getsqlca(): supplied argument is not a valid Informix Result resource in <b>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-30 13:11 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-08-31 15:09 UTC] andreybl at matrix dot co dot il
I am just wondering what feedback it is supposed to get from me while it is obvious, that nothing was changed :)
The problem is the interface to the ifx_getsqlca() function: it is expected that a function receives result_id as a parameter. Here is the function prototype:
array ifx_getsqlca ( int result_id)
When function  ifx_query() or ifx_prepare() fails, the result_id it relurns is FALSE FALSE FALSE !!!!!!!!!!!!!!
And thus this FALSE is qualifid as the "not a valid Informix Result resource" by ifx_getsqlca() function.

We must understand, that there is one global variable of type sqlca structure(actually one per thread) which has the information about the LAST SQL statement. So there should be an option to call the ifx_getsqlca() function without parameter(or may be null/false value for result_id) meaning that I want the sqlca of the LAST sql statement performed.

So, please, if there is a possibility to fix this bug do NOT just send me email in hope that I will not answer :)
 [2005-09-04 23:48 UTC] sniper@php.net
RTFM:
"Returns a positive Informix result identifier on success, or FALSE on error."

And even if you think this is wrong, we won't change it.

 [2005-09-05 00:11 UTC] andreybl at matrix dot co dot il
Ok, ok :)
Just let's take it easy. I do RTFM. I also realise that I am among a minority of Informix users and this bug(?) is not of the higher importance :)
But please read my comment(pardon my english). I did NOT say, that ifx_query() returning FALSE is a bug. Never.
What I say is just that there should be an option to call
ifx_getsqlca() function without a parameter, meaning: "get the sqlca of the last sql statement performed".
As we all understand I can not insist to fix this. If not, just tell me, that it is impossible to fix the bug.
 [2005-09-05 09:02 UTC] sniper@php.net
Reclassified as feature/change request. But I don't think anyone is gonna implement this feature unless paid to do so.

 [2009-05-04 15:10 UTC] pajoye@php.net
Report IFX request via pecl.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 23 05:01:31 2024 UTC