|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-07-19 13:33 UTC] ravisen at mail dot ru
Description: ------------ NULL Date converts to empty string Test script: --------------- /* SQL Table CREATE TABLE t_lot_steps ( n_id_lot integer NOT NULL, d_start date ) */ $sql = 'INSERT INTO t_lot_steps( n_id_lot, d_start ) VALUES ( $1, $2 ) '; $bindsData = [ 1, null ]; $conn = pg_connect(...); pg_prepare($conn, '', $sql); pg_execute($conn, '', $bindsData); Expected result: ---------------- Record added to the table Actual result: -------------- E_WARNING pg_execute(): Query failed: ERROR: invalid input syntax for type date: "" PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 14:00:01 2025 UTC |
Just tested this in PHP 7.4.12, on Gentoo, against Postgresql 13.1 And I do get the Expected result (Record added to the table) I also made a reference program in C++ to test the libpq functions directly. Reference code: --------------- #include <array> #include <iostream> #include <libpq-fe.h> int main() { PGconn *conn = PQconnectdb("dbname=test user=postgres password=postgres"); PGresult *result = PQprepare( conn, "", "INSERT INTO t_lot_steps( n_id_lot, d_start ) VALUES ( $1, $2 ) ", 0, nullptr); std::array<const char *, 2> params = {"1", nullptr}; PGresult *returnResult = PQexecPrepared(conn, "", 2, params.data(), nullptr, nullptr, 0); auto status = PQresultStatus(returnResult); PQfinish(conn); return 0; }