gpt4 book ai didi

PHP mysql_fetch_assoc 仅返回 1

转载 作者:行者123 更新时间:2023-11-29 12:48:01 24 4
gpt4 key购买 nike

我这里有一个我根本无法弄清楚的问题。 mysql_fetch_assoc 返回的每个“数组”的值为 1。
我已经包含了大部分代码(它有点复杂,所以我在下面提供了解释),因为我不知道任何 solr 操作是否可能影响任何 mysql_* 操作。

$server_details = array(
'hostname' => SOLR_SERVER_HOSTNAME,
'login' => SOLR_SERVER_USERNAME,
'password' => SOLR_SERVER_PASSWORD,
'port' => SOLR_SERVER_PORT,
);
//connect to mysql database
$db = 'name';
$db_connect = mysql_connect('localhost:3306', $db, getPassword($db));
$mysql_select_db($db, $db_connect);
$query = "SELECT * FROM table ORDER BY value ASC;";
$result = mysql_query($lss_query, $db_connect);

while($row = mysql_fetch_assoc($result))
print_r($row);//this prints out all of my data, not ones.

//connect and make query for solr database
$solr_client = new SolrClient($server_details);
$solr_query = new SolrQuery();
$solr_query->setQuery('*:*');

//decide size of discretizations of solr and mysql databases
$query_interval = round(mysql_num_rows($result) / 10);
$counter = 0;
$solr_query->setRows($query_interval);

while($counter < mysql_num_rows($result))
{
$sql_array = array(array());

$base_counter = $counter;

//query solr
$solr_query->setStart($counter);
$solr_response = $solr_client->query($solr_query);
$solr_result_xml = $solr_response->getResponse();

mysql_data_seek($result, $counter);
while($row = mysql_fetch_assoc($result) && ($counter < $base_counter + $query_interval))
{
$counter++;
print_r($row); //prints out a single 1 for each row
//push each mysql into a 2-d array for further processing
array_push($sql_array, $row);
}
//this function changes nothing
generic_function($solr_result_xml, $sql_array);
print_r($sql_array); //prints out a bunch of 1's
unset($sql_array);
}

可能还有其他错误,但请包含当前问题的答案。由于这个问题我还没有完成调试,还没有发现那些问题,如果有的话。
谢谢

最佳答案

Precedence matters.

while(($row = mysql_fetch_assoc($result)) && ($counter < $base_counter + $query_interval))

关于PHP mysql_fetch_assoc 仅返回 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25171673/

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