固定列“ columnname”数据库中不存在pgsql。双引号与单引号错误 [英] Fixing column "columnname" does not exist pgsql in database. Double quote vs single quote error

查看:248
本文介绍了固定列“ columnname”数据库中不存在pgsql。双引号与单引号错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格评论(电影ID,用户ID,评论文本,日期,时间,喜欢,状态)/
我收到了错误

I have a table review(movie_id, user_id, reviewtext, date, time, likes, status)/ I get the error

column "exist" does not exist LINE 1: INSERT INTO review values ($1, $2, $3,$4,$5 ,0,"exist") ^ )

当我要将值插入到PostgreSQL数据库中时。我再也无法修改代码了,所以有什么办法可以像添加列那样通过更改数据库来完成这项工作?

when I want to insert values into a postgresql database. I can not modify the code anymore so is there any way to make this work by altering the database like adding a column?

要插入的代码如下:

 $query = $this->db->prepare('INSERT INTO review values (:movieid, :userid, :review,:date,:time ,0,"exist")');
 $result = $query->execute(Array(':movieid' => $movieid, ':userid' => $userid, ':review' => $review, ':date' => $date, ':time' => $time));

我知道解决此问题的一种方法是对状态列使用单引号,但是我唯一能做的就是更改数据库。

I understand that a way to fix this is to use single quotes for the column 'status' but the only thing I can do is alter the database.

推荐答案

不行。

如果您使用了正确的插入-带有命名列:

If you had used proper insert - with named columns:

insert into review (column1, column2, column3) values (....)

那么从理论上讲,可以通过添加 exist列来实现和一个触发器。但这将非常远离理智的解决方案。

then it could be theoretically possible to do by adding column "exist" and a trigger. But this would be very far away from being sane solution.

这篇关于固定列“ columnname”数据库中不存在pgsql。双引号与单引号错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆