0
현재 코드에서 행 수를 확보하는 데 문제가 있습니다. 내가 그것을 행의 수를 반환하고 마지막으로 $ 행보다 큰 3 다음 작동 여부를 확인하려면 내가 함수 getAllBananaindoor (에서 데이터베이스의 데이터를 받기에mysql 문의 행 수를 구하고 리턴하는 방법은 무엇입니까?
$app->get('/banana/:state', function($state) use ($app){
$db = new DbOperation();
$today = date("j-M-Y");
if($state == "Indoor"){
$result = $db->getAllbananaindoor($today);
$response = array();
$response['messages'] = array();
$row = $result->fetch_assoc();
if($row > 3){
$temp = array();
$temp['text'] = 'Yes, you can plant banana seeds today indoors.';
array_push($response['messages'],$temp);
}
else {
$temp = array();
$temp['text'] = 'Nope. Today is not a good time to plant banana seeds indoors.';
array_push($response['messages'],$temp);
}
echoResponse(200,$response);
}
}
public function getAllbananaindoor($today){
$stmt = $this->con->prepare("SELECT * FROM garden WHERE humid >? AND time=? AND temp BETWEEN ? AND ?");
$hum = '50';
$one = '19';
$two = '24';
$stmt->bind_param("iiii",$hum, $today, $one, $two);
$stmt->execute();
$students = $stmt->get_result();
$stmt->close();
return $students;
}
) 대신에 결과를 반환 : 여기 내 코드입니다 그걸로. 내가 어떻게 할 수 있니? 도와주세요.
'$ stmt-> bind_param'은 PDO가 아니고 MySQLi입니다. – hjpotter92