我有一个用于管理用户的类,一切正常,直到我必须向表中添加更多列并修改2个名称。现在其中一个修改过的名称,返回列内容的函数不起作用,colum是填充数据但是当我调用函数时它没有打印任何内容。
我多次重新检查代码,寻找一个糟糕的打字名称或者什么,但一切似乎都没问题,我找不到问题......
这是我的班级:
require_once('aet.php');
class staff {
private $aet;
private $not_working_column;
private $working_column;
public function __construct() {
$this->aet = new aet();
}
private function generate($staff) {
$this->not_working_column = $staff->not_working_column;
$this->working_column = $staff->working_column;
}
private function addInformation($stmt) {
$i = 0;
$stmt->bind_result($not_working_column, $working_column);
while ($stmt->fetch()) {
$arrayStaff[$i] = new staff();
$arrayStaff[$i]->setNotWorkingColum($not_working_column);
$arrayStaff[$i]->setWorkingColumn($working_column);
$i++;
}
}
public function StaffFromEmail($email) {
$mysqli = $this->aet->getAetSql();
if ($stmt = $mysqli->prepare("SELECT * FROM staff WHERE email = ? LIMIT 1")) {
$stmt->bind_param('s', $email);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows == 0) {
$exit = false;
}
else {
$arrayStaff = $this->addInformation($stmt);
$this->generate($arrayStaff[0]);
$exit = true;
}
}
return $exit;
}
public function setNotWorkingColum($not_working_column) {
$this->not_working_column = $not_working_column;
}
public function getNotWorkingColum() {
return $this->not_working_column;
}
public function setWorkingColumn($working_column) {
$this->working_column = $working_column;
}
public function getWorkingColumn() {
return $this->working_column;
}
}
以用户可以更新其信息的形式
<div class="item">
<div class="input">
<input type="text" placeholder="" name="staff_info[]" value="<?php echo $staff->getNotWorkingColum(); ?>" />
</div>
</div>
<div class="item">
<div class="input">
<input type="text" placeholder="" name="staff_info[]" value="<?php echo $staff->getWorkingColumn(); ?>" />
</div>
</div>
答案 0 :(得分:0)
我的错,在更改我错过的一个列的名称时:
public function setPersonalPhone($personal_phone) {
$this->phone = $personal_phone;
}
应该是:
public function setPersonalPhone($personal_phone) {
$this->personal_phone = $personal_phone;
}