postgresql nextval 关于序列的问题
我正在尝试在 PHP 中使用 postgresql 'nextval'。如何填写第三行中的括号以便将 TXN_ID 替换为 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)');
谢谢!
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)');
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您没有告诉我们什么是
$DB
变量。我猜你正在使用 PDO。“是否有办法将查询结果存储到 php 变量中”这个问题是一种初学者问题,在 手册。
您必须明白,(从 PHP 的角度来看)
和
之间没有区别。如果您想从任何查询中获取数据值,您总是以相同的标准方式执行:
有帮助。
You did not tell us what is
$DB
variable. I guess you are using PDO.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.
You must understand, that (from PHP's point of view) there is no difference between
and
If you want to fetch data values from ANY query, you do it always the same, standard way:
Hope that helps.
尝试:
Try:
我不确定与 SET CONSTRAINTS ALL DEFERRED 的交互,但是您是否尝试过这样做:
现在的问题是“undo_transaction”返回什么?如果成功完成后返回交易 ID,那么您就可以开始了!
I'm not sure about the interaction with SET CONSTRAINTS ALL DEFERRED, but have you tried doing this:
The question is now what does "undo_transaction" return? If it returns the transaction ID upon successful completion, then you're good to go!