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

[PHP]Return value is not correct when passing a date parameter to cubrid_bind method

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: PHP-8.4.1
    • Fix Version/s: PHP 9.1.0 0004
    • 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 is not correct when passing a date parameter to cubrid_bind method

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

      [php@NC-PL-QA014 _02_prepare]$ cat bind_time_test.phpt 
      <?php
      $conn = cubrid_connect("localhost", 33113, "phpdb"); 
      cubrid_execute($conn, 'DROP TABLE IF EXISTS time_tb');
      $sql = <<<EOD
      CREATE TABLE time_tb(c1 string, time_tb time,date_t date);
      EOD;
      cubrid_execute($conn,$sql);
      
      //date time type
      $req = cubrid_prepare($conn, "INSERT INTO time_tb VALUES('time date test',?,?);");
      cubrid_bind($req, 1, '02:22:22','time');
      //cubrid_bind($req, 2, '08/14/1977');
      cubrid_bind($req, 2, '08/14/1977','date');
      cubrid_execute($req);
      
      $req2= cubrid_execute($conn, "SELECT * FROM time_tb where c1 like 'time%';");
      if($req2){
         $result = cubrid_fetch_assoc($req2);
         var_dump($result);
         cubrid_close_prepare($req2);
      }
      print 'Finished!';
      cubrid_disconnect($conn);
      ?>
      

      Actual result:

      array(3) {
        ["c1"]=>
        string(14) "time date test"
        ["time_tb"]=>
        string(8) "02:22:22"
        ["date_t"]=>
        string(10) "0000-00-00"
      }
      

      Expect result:

      array(3) {
        ["c1"]=>
        string(14) "time date test"
        ["time_tb"]=>
        string(8) "02:22:22"
        ["date_t"]=>
        string(10) "1977-08-14"
      }
      

        Activity

        Hide
        hellohuizhang 张慧 added a comment -

        This situation is up to cci_bind_param() function.

        1. cubrid_bind ($req, "08/14/1977", "date")
        If you specify the type to "date", the value you bind must be in the form of yyyy/mm/dd, so it will be OK if you use cubrid_bind ($req, "1977/8/14", 'date') or cubrid_bind ($req, "1977/08/14", 'date').

        2. cubrid_bind ($req, "08/14/1977")
        If you don't specify the type you bind, it will adjust it automatically. You can use the following forms to bind values whose type is date:
        cubrid_bind ($req, "8/14/1977");
        cubrid_bind ($req, "2012/8/14");
        cubrid_bind ($req, "2012-8-14");
        ... ...

        In the test case, you bind a string "08/14/1977" and specify the type 'date', CCI will parse it and the result is that year is 8, month is 14 and day is 1977. It is an invalid string. However, CCI won't report an error and bind "0000-00-00" in the related column.

        So I don't know it is a bug for CCI ?

        Show
        hellohuizhang 张慧 added a comment - This situation is up to cci_bind_param() function. 1. cubrid_bind ($req, "08/14/1977", "date") If you specify the type to "date", the value you bind must be in the form of yyyy/mm/dd, so it will be OK if you use cubrid_bind ($req, "1977/8/14", 'date') or cubrid_bind ($req, "1977/08/14", 'date'). 2. cubrid_bind ($req, "08/14/1977") If you don't specify the type you bind, it will adjust it automatically. You can use the following forms to bind values whose type is date: cubrid_bind ($req, "8/14/1977"); cubrid_bind ($req, "2012/8/14"); cubrid_bind ($req, "2012-8-14"); ... ... In the test case, you bind a string "08/14/1977" and specify the type 'date', CCI will parse it and the result is that year is 8, month is 14 and day is 1977. It is an invalid string. However, CCI won't report an error and bind "0000-00-00" in the related column. So I don't know it is a bug for CCI ?
        Hide
        xiaoshan78 李成龙[이성룡] added a comment -

        CCI Bug

        Show
        xiaoshan78 李成龙[이성룡] added a comment - CCI Bug
        Hide
        zoujing ZouJing added a comment -

        Caused by cci

        Show
        zoujing ZouJing added a comment - Caused by cci
        Hide
        zoujing ZouJing added a comment -

        This issue is caused by CCI. I will attach the bts issue number later .

        Show
        zoujing ZouJing added a comment - This issue is caused by CCI. I will attach the bts issue number later .
        Hide
        zoujing ZouJing added a comment -
        Show
        zoujing ZouJing added a comment - CUBRIDSUS-8039
        Hide
        cn15800 谢韦华[Bert] added a comment -

        CCI 9.1.0:

        Warning: Error: DBMS, -176, Conversion error in date format. in /mnt/hgfs/share/share_build/nginx_clent/script/apis120.php on line 14
        bool(false) Finished!

        Show
        cn15800 谢韦华[Bert] added a comment - CCI 9.1.0: Warning: Error: DBMS, -176, Conversion error in date format. in /mnt/hgfs/share/share_build/nginx_clent/script/apis120.php on line 14 bool(false) Finished!
        Hide
        ryin005 Ray Yin added a comment - - edited

        Added case for the issue

        [php@NC-PL-QA011 _14_issues]$ svn ci --username cn14323 -m "[APIS-120] Added a case to test passing a date parameter to cubrid_bind either in correct or incorrect format"
        Adding         _14_issues/bug_apis_120
        Adding         _14_issues/bug_apis_120/cases
        Adding         _14_issues/bug_apis_120/cases/bug_apis_120.phpt
        Adding         _14_issues/bug_apis_120/cases/bug_apis_120.sh
        Adding         _14_issues/bug_apis_120/cases/connect.inc
        Transmitting file data ...
        Committed revision 1976.
        

        case link: http://svn.cubrid.org/cubridapis/php/branches/RB-9.1.0_static_cci/tests2/php/_14_issues/bug_apis_120/

        Show
        ryin005 Ray Yin added a comment - - edited Added case for the issue [php@NC-PL-QA011 _14_issues]$ svn ci --username cn14323 -m "[APIS-120] Added a case to test passing a date parameter to cubrid_bind either in correct or incorrect format" Adding _14_issues/bug_apis_120 Adding _14_issues/bug_apis_120/cases Adding _14_issues/bug_apis_120/cases/bug_apis_120.phpt Adding _14_issues/bug_apis_120/cases/bug_apis_120.sh Adding _14_issues/bug_apis_120/cases/connect.inc Transmitting file data ... Committed revision 1976. case link: http://svn.cubrid.org/cubridapis/php/branches/RB-9.1.0_static_cci/tests2/php/_14_issues/bug_apis_120/
        Hide
        ryin005 Ray Yin added a comment - - edited

        Test OS: Linux 32/64, Windows 32/64
        CUBRID Server: CUBRID 9.1 (9.1.0.0212)
        PHP Version: PHP 5.4.15
        CUBRID-PHP: 9.1.0.0004 svn: http://svn.cubrid.org/cubridapis/php/branches/RB-9.1.0_static_cci/
        Test Tool: PHP Tester (PHPT)

        Test Result: Pass

        Notes: the error message is returned from cubrid_execute() but not cubrid_bind(), it could be ok since the error is caused by that DBMS doesn't support the date format like 'MM/DD/YYYY'. The cubrid_bind() only returns false if the $bind_value doesn't match $bind_value_type

        Show
        ryin005 Ray Yin added a comment - - edited Test OS: Linux 32/64, Windows 32/64 CUBRID Server: CUBRID 9.1 (9.1.0.0212) PHP Version: PHP 5.4.15 CUBRID-PHP: 9.1.0.0004 svn: http://svn.cubrid.org/cubridapis/php/branches/RB-9.1.0_static_cci/ Test Tool: PHP Tester (PHPT) Test Result: Pass Notes: the error message is returned from cubrid_execute() but not cubrid_bind(), it could be ok since the error is caused by that DBMS doesn't support the date format like 'MM/DD/YYYY'. The cubrid_bind() only returns false if the $bind_value doesn't match $bind_value_type

          People

          • Assignee:
            jinhu 李金虎
            Reporter:
            zoujing ZouJing
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: