왜 _sth 객체에서 fetchAll 메소드를 사용하기 때문에 Call to a member function fetchAll() on a non-object
오류를 반환하는지 알지 못합니다.비 객체의 fetchAll() 멤버 함수 호출
아무도 왜 이것을하는지 알 수 있습니까?
FormValidator PHP
$users = $this->_db->query("SELECT * FROM $ruleValue WHERE $input = ?", array($inputValue));
if($users->count()) {
$this->addError($input, $rule);
}
방법
public function query($sql, $params = array()) {
$this->_sth = $this->_dbh->prepare($sql);
if($this->_sth = $this->_sth->execute($params)) {
return $this->_sth->fetchAll(PDO::FETCH_OBJ);
}
return false;
}
(http://stackoverflow.com/questions/23200937/pdo-query-method-with-bindvalue-seems-not- to-be-working), 같은 결과와 함께. –
함수에서 왜이 코드를 사용하고있는 것입니까? 그렇기 때문에 동일한 코드를 반복해서 반복 할 필요가 없습니다. –
'execute()'는 부울을 반환합니다. 그것은'fetchAll()'함수를 가지고 있지 않습니다. 그냥'if ($ this -> _ sth -> execute ($ params)) {'. –