|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-01-16 15:25 UTC] rangercairns@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: rangercairns
[2017-01-16 15:25 UTC] rangercairns@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 17:00:01 2025 UTC |
Description: ------------ If I have the prepared SQL statement INSERT INTO WEBLIB.justin(recieved_date) VALUES(?), where recieved_date is a timestamp, I cannot pass a DateTime object into it. I can however, pass it if I format it with ->format('Y-m-d H:i:s'), which is the native DB2 format. I think the driver should handle the casting from dateTime on its own. Test script: --------------- CREATE TABLE WEBLIB.JUSTIN( id INT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) CONSTRAINT WEBLIB.PK_JUSTIN PRIMARY KEY, recieved_date TIMESTAMP NOT NULL ); <?php $cn = db2_connect('', '', ''); $sql = "INSERT INTO WEBLIB.justin(recieved_date) VALUES(?);"; $stmt = db2_prepare($cn, $sql); #this line will work db2_execute($stmt, [(new DateTime('1981-04-28'))->format('Y-m-d H:i:s')]); # This line does not work db2_execute($stmt, [new DateTime('2001-09-11')]); db2_close($cn); ?>