在postgresql中激发insert查询时显示错误,但它无法在我的postgresql插入数据.为什么


Error display while i fire insert query in postgresql , but it can not insert the data in my postgresql. why?

INSERT INTO soma_user_unit_booking ( 
    uid, book_status, book_datetime, dom_id, from_date, to_date, from_time, to_time, event
) VALUES ( 
   '4','1','2016-07-18 18:01:04','27','2016-07-20','2016-07-20','11:00','11:30','Booking'
)
  • 我尝试在服务器中执行插入查询。并在服务器上安装了postgresql数据库
  • 当我执行这个插入查询时,数据不会插入到数据库中。以及一个错误显示(最后附上的图像(。数据无法在数据库中插入记录
  • 另一个是,当我在admin中的pgadmin中调用静态查询execute时,如果我选中(Paginate results(选项,那么查询不会运行,当取消选中它时,它将在Postgre数据库中成功运行

你能告诉我如何解决这些问题吗?

为了参考这些图像,我在其中检查并取消了服务器数据库中的paginate选项。

执行时显示这些错误

尝试使用PDO。这里有一个简单的例子:

try { $db = new PDO(DB_DRIVER . ":dbname=" . DB_DATABASE . ";host=" . DB_SERVER, DB_USER, DB_PASSWORD);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare("INSERT INTO countries(name, capital, language) VALUES (:country, :capital, :language)");
$stmt->bindParam(':country', $country);
$stmt->bindParam(':capital', $capital);
$stmt->bindParam(':language', $language);
if($stmt->execute()) {
  echo '1 row has been inserted';  
}
$db = null;} catch(PDOException $e) {
trigger_error('Error occured while trying to insert into the DB:' . $e->getMessage(), E_USER_ERROR); }