无法将dataType时间戳保存到PostgreSQL

时间:2018-07-28 14:26:17

标签: php postgresql

我试图将数据插入到PostgreSQL表中,我从表单中以字符串形式获取日期,但最终出现此错误

  

错误:格式不正确的数组文字:“”第2行:... d','2018-07-27 00:00:00','2018-07-27 00:00:00',“,' ',1,1,'',... ^详细信息:数组值必须以“ {”或维信息开头。

这是我的查询

insert into events (title,location,description,start_date,end_date,start_time,end_time,is_pet,is_child,untill,repeat) values ('test','asdasd','asdasd',2018-07-27 00:00:00,2018-07-27 00:00:00,'','',1,1,'','Does Not Repeat')

我的查询就这样解析

$query = "insert into events (title,location,description,start_date,end_date,start_time,end_time,is_pet,is_child,untill,repeat) values 
          ('$title','$location','$description',$start_date,$end_date,'$start_time','$end_time',$is_pet,$is_child,'$until','$repeat')";

$sql = pg_query($query);
if (!$sql) {
    echo pg_last_error($db);
} else {
    echo "Records created successfully\n";
}

我的架构如下

CREATE TABLE public.events (
    id integer NOT NULL,
    title character varying(255),
    location character varying(255),
    description character varying(255),
    end_date timestamp without time zone,
    start_time character varying(20),
    end_time character varying(20)[],
    image character varying(500),
    is_pet boolean,
    is_child boolean,
    repeat character varying,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    posted_by character varying(255),
    email character varying(255),
    untill date,
    start_date timestamp without time zone
);

0 个答案:

没有答案