Я пытаюсь вставить данные в таблицу с помощью PHP и получаю следующую ошибку:
Исправимая фатальная ошибка: объект класса Users не может быть преобразован
вставить в C: \ xampp \ htdocs \ POO \ PDO \ crudPdoCadastra \
классы \ usuarios.php в строке 40
require_once 'crud.php';
class Usuarios extends Crud{
protected $table = 'clientes';
private $nome;
private $email;
private $idade;
//setters
public function setNome($nome){
$this -> nome = $nome;
}
public function setEmail($email){
$this -> email = $email;
}
public function setIdade($idade){
$this -> idade = $idade;
}
//getters
public function getNome(){
return $this -> nome;
}
public function getEmail(){
return $this -> email;
}
public function getIdade(){
return $this -> idade;
}
public function insert(){
// THE ERROR OCCURS ON THE LINE BELOW
$sql = "INSERT INTO $this -> table(nome, email, idade) VALUES(:nome, :email, :idade)"; //THE ERROR OCCURS THIS LINE
$stmt = DB::prepare($sql);
$stmt -> bindParam(':nome', $this -> nome);
$stmt -> bindParam(':email', $this -> email);
$stmt -> bindParam(':idade', $this -> idade);
return $stmt -> execute();
}
public function update($id){
$sql = "UPDATE $this -> table SET nome = :nome, email = :email, idade = :idade WHERE id = :id)";
$stmt = DB::prepare($sql);
$stmt -> bindParam(':nome', $this -> nome);
$stmt -> bindParam(':email', $this -> email);
$stmt -> bindParam(':idade', $this -> idade);
$stmt -> bindParam(':id', $id);
return $stmt -> execute();
}
}
Цель - вставить данные в таблицу