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

[PHP]Return value of cubrid_fetch_lengths method is empty when record number is 1

    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: Return value of cubrid_fetch_lengths method is empty when record number is 1

      Repro steps:
      1. execute: fetch_lengths_test2.phpt
      statements in fetch_lengths_test2.phpt

      [php@NC-PL-QA014 _07_fetch]$ cat fetch_lengths_test2.phpt 
      <?php
      $conn = cubrid_connect("localhost", 33113, "phpdb"); 
      cubrid_execute($conn, 'DROP TABLE IF EXISTS fetch_length_tb');
      cubrid_execute($conn,"CREATE TABLE fetch_length_tb(c1 int, c2 varchar(20))");
      cubrid_execute($conn,"insert into fetch_length_tb(c1,c2) values(1,'varchar1')");
      //cubrid_execute($conn,"insert into fetch_length_tb(c1,c2) values(2,'varchar2')");
      
      $result=cubrid_execute($conn,"select * from fetch_length_tb");
      $row = cubrid_fetch_row($result);
      print_r($row);
      
      $lens = cubrid_fetch_lengths($result);
      print_r($lens);
      
      cubrid_disconnect($conn);
      
      print "Finished!\n";
      ?>
      

      Actual result:

      [php@NC-PL-QA014 _07_fetch]$ php fetch_lengths_test2.phpt 
      Array
      (
          [0] => 1
          [1] => varchar1
      )
      Finished!
      

      Expect result:

      Array
      (
          [0] => 1
          [1] => varchar1
      )
      Array
      (
          [0] => 1
          [1] => 8
      )
      Finished!
      

        Activity

        Hide
        hellohuizhang 张慧 added a comment -

        Hello!

        cubrid_fetch_lengths will return an numeric array with the lengths of the values of each field from the current row of the result set.

        In the test scenario, there is only one row in the table. After cubrid_fetch_row, there are no more rows in the table, so cubrid_fetch_lengths will return FALSE. There are no problem with the output.

        Show
        hellohuizhang 张慧 added a comment - Hello! cubrid_fetch_lengths will return an numeric array with the lengths of the values of each field from the current row of the result set . In the test scenario, there is only one row in the table. After cubrid_fetch_row, there are no more rows in the table, so cubrid_fetch_lengths will return FALSE. There are no problem with the output.
        Hide
        zoujing ZouJing added a comment -

        Statement:

        $conn = cubrid_connect("localhost", 33113, "phpdb"); 
        cubrid_execute($conn, 'DROP TABLE IF EXISTS fetch_length_tb');
        cubrid_execute($conn,"CREATE TABLE fetch_length_tb(c1 int, c2 varchar(20))");
        cubrid_execute($conn,"insert into fetch_length_tb(c1,c2) values(1,'char1'),(2222,'varchar22222222222')");
        
        $result=cubrid_execute($conn,"select * from fetch_length_tb order by c1");
        $row = cubrid_fetch_row($result);
        print_r($row);
        
        $lens = cubrid_fetch_lengths($result);
        print_r($lens);
        

        1. this table contain two records
        2. first: execute cubrid_fetch_row statement

        $row = cubrid_fetch_row($result);
        print_r($row);
        

        return the first record
        3. second: execute cubrid_fetch_lengths statement

        $lens = cubrid_fetch_lengths($result);
        print_r($lens);
        

        4. Actual result:

        [php@NC-PL-QA014 bug]$ php fetch_lengths_test2.phpt 
        Array
        (
            [0] => 1
            [1] => char1
        )
        Array
        (
            [0] => 1
            [1] => 5
        )
        Finished!
        


        Return the lengths is about first record
        Return the lengths isn't about the second record

        According the above result:
        whether using cubrid_fetch_row method, the return value about one record can't be influnenced using cubrid_fetch_length method.

        Show
        zoujing ZouJing added a comment - Statement: $conn = cubrid_connect("localhost", 33113, "phpdb"); cubrid_execute($conn, 'DROP TABLE IF EXISTS fetch_length_tb'); cubrid_execute($conn,"CREATE TABLE fetch_length_tb(c1 int, c2 varchar(20))"); cubrid_execute($conn,"insert into fetch_length_tb(c1,c2) values(1,'char1'),(2222,'varchar22222222222')"); $result=cubrid_execute($conn,"select * from fetch_length_tb order by c1"); $row = cubrid_fetch_row($result); print_r($row); $lens = cubrid_fetch_lengths($result); print_r($lens); 1. this table contain two records 2. first: execute cubrid_fetch_row statement $row = cubrid_fetch_row($result); print_r($row); return the first record 3. second: execute cubrid_fetch_lengths statement $lens = cubrid_fetch_lengths($result); print_r($lens); 4. Actual result: [php@NC-PL-QA014 bug]$ php fetch_lengths_test2.phpt Array ( [0] => 1 [1] => char1 ) Array ( [0] => 1 [1] => 5 ) Finished! Return the lengths is about first record Return the lengths isn't about the second record According the above result: whether using cubrid_fetch_row method, the return value about one record can't be influnenced using cubrid_fetch_length method.
        Hide
        hellohuizhang 张慧 added a comment -

        Commit rev: 486

        Show
        hellohuizhang 张慧 added a comment - Commit rev: 486
        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: