php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74104 ibase_query and date as a param
Submitted: 2017-02-15 19:33 UTC Modified: 2021-03-31 11:39 UTC
From: mikedeweese at hotmail dot com Assigned:
Status: Suspended Package: InterBase related
PHP Version: 7.0.15 OS: CentOS 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mikedeweese at hotmail dot com
New email:
PHP Version: OS:

 

 [2017-02-15 19:33 UTC] mikedeweese at hotmail dot com
Description:
------------
The interbase.so extension parses dates that have two digit years wrong.

In php.ini, ibase.dateformat = "%m/%d/%Y"

I am able to get correct results by editing function ibase_query.c, function _php_ibase_bind, forcing "#ifdef HAVE_STRPTIME" to fail, which causes firebird sql to to parse the string.

This does not fail on my Windows boxes.

Test script:
---------------
CREATE TABLE Z_DEBUG (
    FID    INTEGER,
    FDATE  DATE
);
CREATE OR ALTER TRIGGER Z_DEBUG_BI0 FOR Z_DEBUG
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
  NEW.FID = NEXT VALUE FOR GEN_MYGEN;
END

<?php
ibase_connect('localhost:TEST', 'sysdba', 'masterkey');
$q = ibase_query("INSERT INTO Z_DEBUG (FDATE) VALUES(?) RETURNING (FID)", '3/6/17');
$r = ibase_fetch_object($q);
$q2 = ibase_query("SELECT FDATE, extract(year from FDATE) as FYEAR FROM Z_DEBUG WHERE FID = ?", $r->FID);
$r2 = ibase_fetch_object($q2);
print $r2->FDATE . ' ' . $r2->FYEAR . "\n\n";


Expected result:
----------------
03/06/2017  2017


Actual result:
--------------
03/06/17  17

That is the year 0017, 17 years after 1 BC

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-03-23 18:34 UTC] lester at lsces dot co dot uk
Unable to recreate ...
%Y gives year as 4 characters, and %y trims it to 2 characters
 [2019-03-23 20:13 UTC] lester at lsces dot co dot uk
I have been unable to recreate this on 7.0.31 or 7.2.16 ... 
The two options for dateformat year are %Y for a 4 digit year, and %y for a two digit year and this is working fine as either first or last segment. Our problem with dates here is that Firebird expects M/D/Y so everything has to be coded Y-M-D to avoid the day month problem. But in all cases FYEAR is returned as 4 digits. 

strptime is available on the test machines ... but noting the comment on the manual entry, this probably needs upgrading to date_parse_from_format ?
 [2021-03-31 11:39 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2021-03-31 11:39 UTC] cmb@php.net
The interbase extension is moved to PECL[1] as of PHP 7.4.0, and
is looking for a new maintainer.  Until a new maintainer is found,
I suspend this ticket.

Consider to use the bundled PDO_Firebird extension, or the
php-firebird package[2] instead.

[1] <https://pecl.php.net/package/interbase>
[2] <https://github.com/FirebirdSQL/php-firebird>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC