序列的PostgreSQL nextval问题 [英] postgresql nextval question on sequences

查看:689
本文介绍了序列的PostgreSQL nextval问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在PHP中使用postgresql的 nextval。如何在第三行中填写括号,以便用nextval('schemadb.audit_txn_seq')的值替换TXN_ID?

I am trying to work with postgresql 'nextval' in PHP. How can I fill in the parenthesis in the third line in order to replace TXN_ID with the value of nextval('schemadb.audit_txn_seq')?

$DB->query("SELECT nextval('schemadb.audit_txn_seq')");
$DB->query('SET CONSTRAINTS ALL DEFERRED');
$DB->query('SELECT schemadb.undo_transaction(TXN_ID)');

谢谢!

推荐答案

您没有告诉我们什么是 $ DB 变量。我猜您正在使用PDO。

You did not tell us what is $DB variable. I guess you are using PDO.

是否有将查询结果存储到php变量中的问题是一种初学者的问题,在< a href = http://www.php.net/manual/zh/book.pdo.php rel = nofollow noreferrer>手册。

The question "Is there anyway to store the result of query into php variable" is kind of beginner question, and is easilly answered in the manual.

您必须了解,(从PHP的角度来看)

You must understand, that (from PHP's point of view) there is no difference between

SELECT nextval('schemadb.audit_txn_seq')

SELECT xcolumn FROM xtable LIMIT 1

如果要从中获取数据值任何查询都以相同的标准方式执行:

If you want to fetch data values from ANY query, you do it always the same, standard way:


  1. query

  2. execute

  3. 获取

希望有帮助。

这篇关于序列的PostgreSQL nextval问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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