Php 如何在PostgreSQL表中插入日期值?
如何在PostgreSQL中插入日期?这似乎是错误的:Php 如何在PostgreSQL表中插入日期值?,php,postgresql,Php,Postgresql,如何在PostgreSQL中插入日期?这似乎是错误的: public function insert( $name, $author ) { $this->query = "INSERT INTO people ( name, author, date ) VALUES ( '$name', '$author', to_timestamp('2/3/2016 12:05')"; return $result = pg_query( $this->connec
public function insert( $name, $author ) {
$this->query = "INSERT INTO people ( name, author, date )
VALUES ( '$name', '$author', to_timestamp('2/3/2016 12:05')";
return $result = pg_query( $this->connection, $this->query );
}
$database->insert( 'someName', 'SomeAuthor' );
“2016-03-02 12:05:00”是一种方式
$this->query = "INSERT INTO people ( name, author, date )
VALUES ( '$name', '$author', '2016-03-02 12:05:00')";
问题是你没有使用参数来传递参数。您使用的是日期/时间的非标准格式。