简体   繁体   English

为什么此查询返回不同的值?

[英]Why does this query return different values?

I'm trying to pull information from my database, but the query I'm using is only pulling all of the values after the first one. 我正在尝试从数据库中提取信息,但是我正在使用的查询仅提取第一个之后的所有值。 I have no LIMIT set, but I did try setting a LIMIT 0,30 with no change. 我没有设置LIMIT ,但我确实尝试设置了LIMIT 0,30 ,没有任何变化。 In phpMyAdmin, the query returns what I expect. 在phpMyAdmin中,查询返回我期望的结果。 In my PHP file, it returns what I've explained. 在我的PHP文件中,它返回我所解释的内容。

The query is : 查询是:

SELECT * FROM `mainSite_others` WHERE forGame='$gameName'

gameName is previously provided, and I suspect no errors because it does return at least two values. gameName是先前提供的,我怀疑没有错误,因为它确实返回至少两个值。 The forGame value in the database is all the same, a constant "+Stellar+Dawn" . 数据库中的forGame值都是相同的,一个常量"+Stellar+Dawn"

The PHP code is: PHP代码是:

while ($gameOther = $database->fetchArray($gameOtherQry)) { 
    echo $gameOther['otherName'];
}

Don't worry about the $database->fetchArray part, that is just my DB class, which works fine as far as I know. 不用担心$database->fetchArray部分,那只是我的数据库类,据我所知,它可以正常工作。

The table I am extracting from looks like this (this is with all the values contained): 我从中提取的表如下所示(包含所有值):

id    |    forGame    |   otherType    |   otherName    |    otherDesc
9     | +Stellar+Dawn | Character      | Car            | Car
10    | +Stellar+Dawn | Item           | Brugson Burson | a guy
11    | +Stellar+Dawn | Item           | Space Pie      | A pie from space

I am using mySQLi. 我正在使用mySQLi。

Any ideas? 有任何想法吗? Thank you. 谢谢。

在到达while循环之前,您可能正在进行访存调用,这会“丢失”结果的第一行。

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

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