I am using PDO object for executing query in PHP:
$stmt = $this->db->prepare('select email from users where email = :email');
return (bool) $stmt->execute(array(':email' => $email))->fetchColumn();
I am getting error here:
Fatal error: Call to a member function fetchColumn() on a non-object
What is the problem? The $this->db->query()
command is working.
PDOStatement::execute
returns a boolean indicating whether or not the query succeeded. To fetch results, you must call a fetch method on the original statement instance.