从新创建的MYSQL Insert语句中获取信息 [英] Fetching info from a freshly created MYSQL Insert statement

查看:64
本文介绍了从新创建的MYSQL Insert语句中获取信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经放弃了整个mysql_insert_id函数。始终返回0。我在我的数据库中有一个名为ordernumber的自动递增字段,当我从另一个页面查询它时,总是给出45的正确答案。或60或60。管他呢。用户填写第1页上的简单表单。表单信息发布到响应页2.如果一切顺利,用户按照指示(字段验证),用户会得到一个漂亮的漂亮页面打印出来,其中包含他们刚刚填写的所有内容out(现在仍然在第2页)。但是,我还需要用户收到代表他们自动创建的2个字段,即ordernumber。字段和日期字段(yyyy-mm-dd格式)字段。一定有办法。任何帮助将不胜感激。是否有一个唯一的ID在INSERT之前创建锁定,我可以在INSERT之后立即引用,然后返回并获取剩余的2个新字段?谢谢,

JMO

I''ve about give up with the whole mysql_insert_id function. Always returns a "0". I do have an auto-incrementing field in my database called "ordernumber", which when I query it from another page, always gives the right answer of "45" or "60" or whatever. User fills out simple form on page 1. Form info is POSTed to response Page 2. If all goes well, and user does as instructed (field validation), user gets a nice pretty page to print out which contains all the stuff they just filled out (still on Page 2 now). However, I need user to also receive the 2 fields that were automatically created on their behalf, which were the "ordernumber" field and the "date" (yyyy-mm-dd format) field. There must be a way. Any help would be greatly appreciated. Is there a unique ID that creates the lock prior to the INSERT that I can reference immediately after the INSERT to then go back and fetch the remaining 2 new fields? Thanks,
JMO

推荐答案

Heya,JMO。欢迎来到TSDN!


是否只有一个具有此行为的特定查询,或者您是否可以使用任何将数据插入该表的查询重新创建它?
Heya, JMO. Welcome to TSDN!

Is there only a specific query that exhibits this behavior, or can you recreate it with any query that INSERTs data into that table?


这是相关代码。
Here''s the relevant code.
展开 | 选择 | Wrap | 行号


Heya,JMO。


代码包装更好(也更容易)一般来说,当你使用空格时~_ ^


这句话的输出是什么:
Heya, JMO.

Code wraps better (and is easier to decipher in general) when you use whitespace ~_^

What is the output of this statement:
展开 | 选择 | Wrap | 行号


这篇关于从新创建的MYSQL Insert语句中获取信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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