Class Database { public $db; public $name = "root"; public $dsn = "mysql:host=localhost;dbname=Users;charset=UTF-8"; public $password = ""; public function __construct() { $this->db = new PDO($this->dsn, $this->name, $this->password); } public function find_login($login) { $sql = $this->db->query('SELECT login FROM Users WHERE login = {$login}'); return $sql->rowCount(); } public function find_mail($mail) { $sql = $this->db->query('SELECT login FROM Users WHERE mail = {$mail}'); return $sql->rowCount(); } } Fatal error: CallCount () on a non-object in C: \ OpenServer \ domains \ hosting \ Database.php on line 16
In a separate file without properties and methods, everything worked, but here the same error is that it is not an object. As a result, I need to get the number of affected columns or the result itself as a fact. Tried it through $sql->fetch() , the same error.