gpt4 book ai didi

php - oci_bind_by_name RETURNING INTO 截断值

转载 作者:可可西里 更新时间:2023-11-01 13:15:43 25 4
gpt4 key购买 nike

当我向包含 1000 多个条目的表中插入一行并尝试返回行 ID(无论是来自自动增量触发器/序列,还是来自在插入语句中手动设置值)时,我得到一个截断值:

$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, 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, ':id', $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

关于php - oci_bind_by_name RETURNING INTO 截断值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1710617/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com