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

[PHP] cubrid_bind() doesn't support select bit data from a prepared statement

    Details

    • Type: Bug
    • Status: Reopened
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: PHP 9.1.0.0003
    • Fix Version/s: PHP 9.1.0 0004
    • Component/s: PHP Driver
    • Labels:
    • Environment:
      • OS: Linux 64bit
      • CUBRID Server: CUBRID 9.1 (9.1.0.0212) (64bit release build for linux_gnu) (Mar 14 2013 00:16:33)
      • PHP Version: PHP 5.5.0, PHP 5.4.15
      • CUBRID-PHP: PHP 9.1.0.0003

      Description

      • Brief: it is similar as APIS-586, cubrid_bind() doesn't work properly when we select bit data from a prepared statement
      • Test Code {code}
        <?php

        $conn = cubrid_connect("localhost", 33367, "demodb", "dba");

        cubrid_execute($conn, 'DROP TABLE IF EXISTS bit1_tb');
        cubrid_execute($conn,"create table bit1_tb(a1 bit(8))");
        cubrid_execute($conn,"insert into bit1_tb values(B'1010')");

        printf("#####select from bit1_tb #####\n");
        $req1=cubrid_execute($conn,"select * from bit1_tb where a1 = B'1010'");
        if ($req1) {
        $res=cubrid_fetch($req1);
        print_r($res);
        cubrid_close_prepare($req1);
        }

        // Test Point: test the fetch result with cubrid_bind
        $req2=cubrid_prepare($conn,"select * from bit1_tb where a1 = ?");
        cubrid_bind($req2, 1, "B'1010'", "bit");
        cubrid_execute($req2);

        $result = cubrid_fetch_assoc($req2);
        var_dump($result);

        ?>{code}
      • Result
        • Expected Result: #####select from bit1_tb ##### Array ( [0] => A0 [a1] => A0 ) array(1) { ["a1"]=> string(2) "A0" }
        • Actual Result: #####select from bit1_tb ##### Array ( [0] => A0 [a1] => A0 ) bool(false)
      • Summary: The case compares the returned result by using cubrid_execute() and cubrid_bind() (with prepared statement), it returns different data

        Activity

        Hide
        cn15800 谢韦华[Bert] added a comment -

        a cci bug:

        insert into bit1_tb values(B'00001010') ----> data in cubrid: 0x0a right
        insert into bit1_tb values(B'10100000') ----> data in cubrid: 0xa0 right
        insert into bit1_tb values(B'1010') ----> data in cubrid: 0xa0 wrong

        1010 is 00001010,not 10100000.

        Show
        cn15800 谢韦华[Bert] added a comment - a cci bug: insert into bit1_tb values(B'00001010') ----> data in cubrid: 0x0a right insert into bit1_tb values(B'10100000') ----> data in cubrid: 0xa0 right insert into bit1_tb values(B'1010') ----> data in cubrid: 0xa0 wrong 1010 is 00001010,not 10100000.
        Hide
        cn15800 谢韦华[Bert] added a comment -

        I have modify the issue,but there is a bug of bit in cci, so i modify the test case:

        {code}
        <?php

        $conn = cubrid_connect("localhost", 33000, "demodb", "dba");

        cubrid_execute($conn, 'DROP TABLE IF EXISTS bit1_tb');
        cubrid_execute($conn,"create table bit1_tb(a1 bit(8))");
        cubrid_execute($conn,"insert into bit1_tb values(B'00001010')");

        printf("#####select from bit1_tb #####\n");
        $req1=cubrid_execute($conn,"select * from bit1_tb where a1 = B'00001010'");
        if ($req1) {
        $res=cubrid_fetch($req1);
        print_r($res);
        cubrid_close_prepare($req1);
        }

        // Test Point: test the fetch result with cubrid_bind
        $req2=cubrid_prepare($conn,"select * from bit1_tb where a1 = ?");
        cubrid_bind($req2, 1, "1010", "bit");
        cubrid_execute($req2);

        $result = cubrid_fetch_assoc($req2);
        var_dump($result);

        ?>{code}
        Show
        cn15800 谢韦华[Bert] added a comment - I have modify the issue,but there is a bug of bit in cci, so i modify the test case: {code} <?php $conn = cubrid_connect("localhost", 33000, "demodb", "dba"); cubrid_execute($conn, 'DROP TABLE IF EXISTS bit1_tb'); cubrid_execute($conn,"create table bit1_tb(a1 bit(8))"); cubrid_execute($conn,"insert into bit1_tb values(B'00001010')"); printf("#####select from bit1_tb #####\n"); $req1=cubrid_execute($conn,"select * from bit1_tb where a1 = B'00001010'"); if ($req1) { $res=cubrid_fetch($req1); print_r($res); cubrid_close_prepare($req1); } // Test Point: test the fetch result with cubrid_bind $req2=cubrid_prepare($conn,"select * from bit1_tb where a1 = ?"); cubrid_bind($req2, 1, "1010", "bit"); cubrid_execute($req2); $result = cubrid_fetch_assoc($req2); var_dump($result); ?>{code}
        Hide
        cn15800 谢韦华[Bert] added a comment -

        you can excute cubrid_bind as follow:

        cubrid_bind($req2, 1, "00001010", "bit");

        it is same with cubrid_bind($req2, 1, "1010", "bit");

        Show
        cn15800 谢韦华[Bert] added a comment - you can excute cubrid_bind as follow: cubrid_bind($req2, 1, "00001010", "bit"); it is same with cubrid_bind($req2, 1, "1010", "bit");
        Hide
        ryin005 Ray Yin added a comment -

        Similar as APIS-586, to keep the consistency with CUBRID, I suggest to update cubrid_bind() function to make sure that the data is filled with values from the left side (i.e. '1010' => '10100000')

        Reopen the issue

        Show
        ryin005 Ray Yin added a comment - Similar as APIS-586 , to keep the consistency with CUBRID, I suggest to update cubrid_bind() function to make sure that the data is filled with values from the left side (i.e. '1010' => '10100000') Reopen the issue

          People

          • Assignee:
            cn15800 谢韦华[Bert]
            Reporter:
            ryin005 Ray Yin
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: