朋友您好我有问题我想修改一名员工但是它给了我这个错误:致命错误:在C:\ wamp \ www \中的非对象上调用成员函数setcin()第6行的Application \ employe \ update.php 我不明白为什么。 这是我的功能:
public function update(employe $employe){
$this->makes();
$this->st=$this->pdo->prepare("update employe set cin=:cin,nom_em=:nom_em,id_grade=:id_grade,id_affectation=:id_affectation,adress=:adress where id_em=:id_em");
$this->st->bindvalue(':cin',$employe->getcin(),pdo::PARAM_STR);
$this->st->bindvalue(':nom_em',$employe->getnom_em(),pdo::PARAM_STR);
$this->st->bindvalue(':id_grade',$employe->getid_grade(),pdo::PARAM_INT );
$this->st->bindvalue(':id_affectation',$employe->getid_affectation(),pdo::PARAM_INT );
$this->st->bindvalue(':adress',$employe->getadress(),pdo::PARAM_STR);
$exe=$this->st->execute();
}
public function read($id_em){
$this->makes();
$this->st=$this->pdo->prepare("select * from employe where id_em=:id_em");
$this->st->bindvalue(':id_em',$id_em,pdo::PARAM_INT );
$exe=$this->st->execute();
}
这是函数的调用:
<?php
include'manager.php';
$manager=new manager();
$co=$manager->read($_POST["id_em"]);
$co->setcin($_POST['cin']);
$co->setnom_em($_POST['nom_em']);
$co->setid_grade($_POST['id_grade']);
$co->setid_affectation($_POST['id_affectation']);
$co->setadress($_POST['adress']);
$manager->update($co);
?>
谢谢你