因此,我有两个部门department和department,一个department可以为此具有多个名称,我制作了此表格,您可以在其中添加更多名称的输入,我查找了如何将其绑定到模型,但显然不建议这样做。
https://i.stack.imgur.com/AgO1F.png
这些是部门和指定类别
function users($db, $id, $itemsa) {
$sql = "select * from users where id = :aid limit 1";
$st = $db->prepare($sql);
$st -> execute([":aid" => $id]);
// you only have one row returned, so a simple fetch
$row = $st->fetch(PDO::FETCH_ASSOC);
$arra = explode(', ', $itemsa);
$items = "";
foreach ($itemsa as $col ) {
$items .=
"<div class='rtitle' data-id = " . $row['id'] . ">" . mb_strtoupper($row[$col]) . "</div>\n" .
"<div class='rstory' data-id = " . $row['id'] . ">" . $row[$col] . "</div>\n";
}
echo $items;
}
$itemsa = "date, name, phone, address, color, height";
users($db, $id, $itemsa);
}
public class Departement implements Serializable{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id_departement")
private Long idDepartement;
@Column(name="nom_dept")
private String nomDept;
@Column(name="designation")
@OneToMany(fetch = FetchType.EAGER, mappedBy = "departement")
private List<Designation> designation;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "departement")
private List<EmployeSociete> employees;
public Departement() {
}
public Departement(String nomDept, List<Designation> designation, List<EmployeSociete> employees) {
super();
this.nomDept = nomDept;
this.designation = designation;
this.employees = employees;
}
public Long getIdDepartement() {
return idDepartement;
}
public void setIdDepartement(Long idDepartement) {
this.idDepartement = idDepartement;
}
public String getNomDept() {
return nomDept;
}
public void setNomDept(String nomDept) {
this.nomDept = nomDept;
}
public List<Designation> getDesignation() {
return designation;
}
public void setDesignation(List<Designation> designation) {
this.designation = designation;
}
public List<EmployeSociete> getEmployees() {
return employees;
}
public void setEmployees(List<EmployeSociete> employees) {
this.employees = employees;
}
}