Bug #72621 [Com]: pg_execute(): NULL Date converts to empty string
Edit report at https://bugs.php.net/bug.php?id=72621&edit=1
ID: 72621
Comment by: dev at dcolt dot org
Reported by: ravisen at mail dot ru
Summary: pg_execute(): NULL Date converts to empty string
Status: Open
Type: Bug
Package: PostgreSQL related
Operating System: Centos 7
PHP Version: 7.0.8
Block user comment: N
Private report: N
New Comment:
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;
}
Previous Comments:
------------------------------------------------------------------------
[2016-07-19 13:33:04] 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: ""
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72621&edit=1
Thread (3 messages)