当我在一个包含1000个条目的表中插入一行,并尝试返回行ID(来自自动增量触发器/ seq,或者从insert语句中手动设置值)时,我得到一个截断值:
$db = OCIlogon(DATABASE_LOGIN,DATABASE_PASSWORD,DATABASE_NAME); $MysqLdate = date('Y/m/d G:i:s'); $db_vid_id = 748; $authorID = 310; $typeID = 2; $timecode = 47; $shortDescrip = "hello world"; $query = "INSERT INTO TESTTHOUSAND (ID,VIDEO_ID,AUTHOR_ID,TYPE_ID,DATE_CREATED,TIMECODE,SHORT_DESCRIPTION,APPROVED,IS_PUBLIC) VALUES(4067,:videoID,:authorID,:typeID,TO_DATE('$MysqLdate','yyyy/mm/dd HH24:MI:SS'),:timecode,:shortDescrip,0) RETURNING ID INTO :id"; $stmt = oci_parse($db,$query); oci_bind_by_name($stmt,':videoID',$db_vid_id); oci_bind_by_name($stmt,':authorID',$authorID); oci_bind_by_name($stmt,':typeID',$typeID); oci_bind_by_name($stmt,':timecode',$timecode); oci_bind_by_name($stmt,':shortDescrip',$shortDescrip); oci_bind_by_name($stmt,':id',$theID); oci_execute($stmt); oci_free_statement($stmt); oci_commit($db); oci_close($db); echo $theID;
此代码正确执行,并且值正确存储在数据库中.但是,$theID的值是406,而不是4067.
我正在运行PHP 5.2.6和Oracle 10.1
有没有人遇到过这个?
我已经做了一些挖掘,似乎我需要指定这是一个sqlT_INT:
oci_bind_by_name($stmt,$annotationID,-1,sqlT_INT);
从http://www.php.net/manual/en/function.oci-bind-by-name.php#92334起
for numerics use the default length (-1) but tell oracle its an integer
原文地址:https://www.jb51.cc/php/130359.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。