Uploaded image for project: 'CUBRID APIs'
  1. CUBRID APIs
  2. APIS-129

[PHP]Getting value using cubrid_result method will fail when the column value in database is null

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: PHP-8.4.1
    • Fix Version/s: PHP-8.4.1, PHP-Apricot
    • Component/s: PHP Driver
    • Labels:
      None

      Description

      Test Build: CUBRID 2008 R4.1 (8.4.1.1018) (64bit release build for linux_gnu)
      OS: Linux 64
      Description:
      One colume value in database is null.
      Getting value using cubrid_result method will fail.

      Description: in cubrid_result():
      Return Values
      Value of a specific field, on success (NULL if value if null).
      FALSE on failure.

      Repro steps:
      1. execute: php result_test3.phpt
      statements in result_test3.phpt

      $conn = cubrid_connect("localhost", 33113, "demodb");
      cubrid_execute($conn, 'DROP TABLE IF EXISTS tb');
      cubrid_execute($conn,"CREATE TABLE tb(id int, name varchar(10), address string default NULL, phone varchar(10))");
      cubrid_execute($conn,"insert into tb(id,name,phone) values(6,'name6','NULL')");
      $req=cubrid_execute($conn, "SELECT * FROM tb ");
      $value=cubrid_result($req,0,'address');
      if(is_null($value)){
         printf("[001]Expect null [%d] [%s]\n", cubrid_error_code(), cubrid_error_msg());
      }elseif(FALSE == $value ){
         printf("[001] No expect false [%d] [%s]\n", cubrid_error_code(), cubrid_error_msg());
      }else{
         printf("[001]Get result success\n");
         var_dump($value);
      }
      
      

      Actual result:

      [001] No expect false [0] []
      

      Expect result:

      [001]Expect null [0] []
      

      May be the value should be true when using is_null() method to judge the returning value($value=cubrid_result($req,0,'address')).

        Activity

        Hide
        hellohuizhang 张慧 added a comment -

        Commit rev: 488

        Show
        hellohuizhang 张慧 added a comment - Commit rev: 488
        Hide
        zoujing ZouJing added a comment -

        Test build : CUBRID 2008 R4.1 (8.4.1.1018)
        OS: Linux 64bit
        Test Result: PASS
        so i close it

        Show
        zoujing ZouJing added a comment - Test build : CUBRID 2008 R4.1 (8.4.1.1018) OS: Linux 64bit Test Result: PASS so i close it

          People

          • Assignee:
            zoujing ZouJing
            Reporter:
            zoujing ZouJing
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: