데이터베이스 (클래스)에 대한 제약 조건을 확인하기 위해 다음 코드를 사용하고 있습니다. U는 쿼리에 의해 반환되는 행의 수를 얻기 위해 노력하고 내가 라인에서 같은 오류가 계속PHP mySQL numRows() 사용 및 오류?
$count1= $ires1->numRows(MDB2_FETCHMODE_ASSOC);
오류 :
> Call to a member function numRows() on a non-object
내가 내 다른 때문에 내 머리를 잡아 당겨 봤는데 이것과 비슷한 기능은 잘 작동하지만이 기능은 작동하지 않는 유일한 기능입니다. 이 중 하나에서 눈에 띄는 것이 있습니까?
인수 $ DB를 내 데이터베이스에 바로 연결입니다, pno
는 정수이며, essn
텍스트입니다 .. 그래서 내가 뭘 잘못 모르겠어요 ..
<?php
function submitCheck($db){
$essn= $_POST['essn'];
$pno=$_POST['pno'];
$query1 = "select * from works_on where pno=? and essn=?";
$types1 = array('integer','text');
$stmt1 = $db->prepare($query1, $types1, MDB2_PREPARE_MANIP);
if (MDB2::isError($stmt1)) {
print("bad prepared statement:" . $stmt->getMessage());
}
$queryargs1 = array($pno, $essn);
$ires1 = $stmt1->execute($queryargs1);
$count1= $ires1->numRows(MDB2_FETCHMODE_ASSOC);
//print("The project number entered was $count1[pno]");
if(!(count($count1)==0)){
print("The employee is already part of this project! If you want to update the hours, please select update!");
return false;
}
return true;
}
?>
'$ ires1'의 값은 무엇입니까? 쿼리가 실패하고'$ stmt1-> execute'가 어떤 오류 값을 대신 반환 할 수 있습니까? ('false' 또는'null'과 같음) – Halcyon
null 값을 리턴한다고 생각합니다. 이것이 작동하지 않는 이유입니다. – Paul