-1

这是我的代码片段:

    $ftype = "HF Custom";
    $stype = "Custom";
    $mysqli->autocommit(FALSE); 
    for($j = 1; $j < $columns; $j++){
        $fname = $pdata[0][$j];
        $startID++; 
        echo "id: ".$startID. "\n";
        if($isExist[$j] <> 1){
        // insert new admin record  
        $sql = "INSERT INTO `admin_custom` (`Fund_ID`, `user_id`, `Fund_Name`,`Fund_Type`,`Fund_Strategy_Classif_1`) VALUES (?,?,?,?,?)";
        $stmt = $mysqli->prepare($sql);
        $stmt->bind_param('iisss',$startID ,$user_id, $fname, $ftype, $stype);
        $stmt->execute();
        $stmt->close();
        }       
.......
    }
    $mysqli->commit();

问题是当我检查 admin-custom 表中的记录时,所有 Fund_ID 字段都是相同的,并且在进入循环之前等于 $startID。所有其他字段都是正确的,并根据 $pdata 数组进行更改。

回显 $startID 显示正确的递增值,它与进入循环之前分配的唯一值绑定。

这里有什么问题?

更新!!!。我已将 Fund_ID 字段更改为 varchar(64) 并将 bind_param 的类型更改为“字符串”。现在它写入正确的字符串。因此,看起来 int(11) 不足以代表我的 ID --- 需要将其更改为 bigint。

4

1 回答 1

1

根据您在评论中的更新,如果您的字段Fund_ID是 int(11),则最大值为2147483647,这是您的$startId.

改成 BIGINT 会是更好的选择。

于 2013-10-01T02:22:10.780 回答