php – oci_bind_by_name RETURNING INTO截断值

前端之家收集整理的这篇文章主要介绍了php – oci_bind_by_name RETURNING INTO截断值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我在一个包含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.f2er.com/php/130359.html

猜你在找的PHP相关文章