我们曾经用这种方法处理MySQL结果:
$sql = "SQL query here";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
//--- do something for each row
}
}
我的问题是,我们如何创建与while
相关的条件内$result
,例如:
$sql = "SQL query here";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$client_name = $row['client_name'];
//-- step 1 : count how many 'client_name' in $result
//-- step 2 : IF more than 5, do something...
}
}
我的问题是,当我尝试print_r($result)
时,它只给了我:
mysqli_result Object ( [current_field] => 0 [field_count] => 15 [lengths] => [num_rows] => 11606 [type] => 0 )
虽然我想要做的是使用[num_rows] => 11606
执行'搜索和计数'。我们怎么能这样做?
答案 0 :(得分:0)
尝试将该行作为数组提取:
for(i=0; i<headerLength; i++)
{
SPIx->DR = headerBuffer[i];
while ((SPIx->SR & SPI_I2S_FLAG_RXNE) == (uint16_t)RESET);
SPIx->DR ;
}