简体   繁体   English

数据库条目与输出数据不同

[英]Database entry different from outputted data

I have a piece of code that is supposed to count the records based on a service ID in my database. 我有一段代码应该根据数据库中的服务ID对记录进行计数。
This works fine, and outputs fine. 这工作正常,并且输出正常。

However, when I try to store that counted data (The exact same variables that I display properly), the numbers are getting all messed up. 但是,当我尝试存储计数的数据(与我正确显示的变量完全相同)时,数字变得一团糟。

    foreach($sids as $sid) {

    $csv = array($date, $sid);
    $count = $bdb->GetOne("
    SELECT COUNT(*)
    FROM User_Services as us
    INNER JOIN Cust_Info as ci on ci.CustID=us.CustID
    INNER JOIN Services as s on s.ServiceID=us.ServiceID
    WHERE s.ServiceID=? 
    AND ci.Active=1
    ", array($sid));

    $csv[] = $count;

    $bdb->Execute("
        INSERT INTO service_count_snapshot
        VALUES (?,?,?)
    ", array($date, $sid, $count));
    }

I have about 400 Service IDs, and after it gets to 127, it is always entering the Service ID as 127. However, the count of records is entered properly each time. 我大约有400个服务ID,当它达到127后,它始终将服务ID输入为127。但是,每次都正确输入了记录数。

Here is what I mean 这就是我的意思

My question is, is this a coding issue? 我的问题是,这是编码问题吗? Am I processing the data incorrectly? 我处理数据不正确吗? Is it possibly a visual bug, and the data is actually correct? 可能是视觉错误,数据实际上是正确的吗? How can I fix this? 我怎样才能解决这个问题?

Looks like your id field is of the wrong type. 看起来您的id字段类型错误。 Maybe it is just TINYINT - check back that it is of type INT(10) and with UNSIGNED attribute. 也许只是TINYINT请检查它是否为INT(10)类型并具有UNSIGNED属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM