I am using PDO with OOP. I have a code like this:
public function selectOne($id) {
$sql = "SELECT * FROM emps WHERE id = ':id'";
$stmt = $this->connect()->prepare($sql);
$stmt->bindValue(":id", $id);
$stmtExec = $stmt->execute();
if ($stmtExec->rowCount() > 0) {
echo "got results";
} else {
echo 'nothing';
}
}
When I try to run this it gives me an error: Fatal error: Uncaught Error: Call to a member function rowCount() on boolean
Where am I doing wrong. I am new to Php. Thanks!