I have a problem when I try to make an insert of type date to my database in informix from php using pdo. I do not have problems with another type of data, I did the test with the majority For example to make an insert to this table
Create prueba1 (
cod serial,
id int,
nombre varchar(30),
fecha datetime
)
From PHP (there are 2 ways) (first define my connection)
$cona = new PDO("informix:host=10....; service=9040;database=sap2000; server=central1; protocol=onsoctcp;EnableScrollableCursors=1;CLIENT_LOCALE=en_US.CP1252;DB_LOCALE=en_US.819", "xxxxxx", "xxxxxx");
$dato1 = "(0)";
$dato2 = 333;
$dato3 = "ddddaaaannn";
$dato4 = "2016-10-19 09:10:00"
//Manera 1
$sql1 = $cona->prepare("insert into prueba1 values ($dato1, $dato2, '".$dato3."', '".$dato4."')");
$sql1->execute();
//Manera 2
$sql2 = ("insert into prueba1 values ($dato1, $dato2, '".$dato3."', '".$dato4."')");
$result = $cona->query($sql2);
With either of these two forms I have no problems with the insert.
To do the same test it works from the manager of my informix database. insert into test1 values ((0), 73, 'F000', '2016-10-19 08:10:00')
The problem is when I try to make the insert of a data type date
for example if I have a table like this
create table prueba2
(
fecha date
)
doing directly from my manager I have no problem, that is
insert into prueba2 values ('2016-10-30')
The problem is when I do the same from php
From PHP (there are 2 ways) (first define my connection)
$cona = new PDO("informix:host=10....; service=9040;database=sap2000; server=central1; protocol=onsoctcp;EnableScrollableCursors=1;CLIENT_LOCALE=en_US.CP1252;DB_LOCALE=en_US.819", "xxxxxx", "xxxxxx");
$dato1 = "2016-10-30";
//Manera 1
$sql1 = $cona->prepare("insert into prueba2 values ('".$dato1."')");
$sql1->execute();
//Manera 2
$sql2 =("insert into prueba2 values ('".$dato1."')");
$result = $cona->query($sql2);
What is it that I am doing wrong? I also tried formatting my variable date but without any results