本文整理汇总了PHP中Department::addEmployee方法的典型用法代码示例。如果您正苦于以下问题:PHP Department::addEmployee方法的具体用法?PHP Department::addEmployee怎么用?PHP Department::addEmployee使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Department
的用法示例。
在下文中一共展示了Department::addEmployee方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fillDepartment
function fillDepartment(Department $department, array $people)
{
foreach ($people as $value) {
for ($i = 0; $i < $value[0]; $i++) {
$department->addEmployee(new $value[1]($value[2]));
}
}
}
示例2: fillTheDepartment
private function fillTheDepartment(Department $department, $addToDepartment)
{
foreach ($addToDepartment as $item) {
foreach ($item as $count => $employee) {
for ($i = 0; $i < $count; $i++) {
$em = new $employee[0]($employee[1], $employee[2]);
$department->addEmployee($em);
}
}
}
}
示例3: setDepartment
/**
* Declares an association between this object and a Department object.
*
* @param Department $v
* @return Employee The current object (for fluent API support)
* @throws PropelException
*/
public function setDepartment(Department $v = null)
{
if ($v === null) {
$this->setDepartmentId(NULL);
} else {
$this->setDepartmentId($v->getId());
}
$this->aDepartment = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the Department object, it will not be re-added.
if ($v !== null) {
$v->addEmployee($this);
}
return $this;
}
示例4: getName
{
private $_name;
function __construct($name)
{
$this->_name = $name;
}
function getName()
{
return $this->_name;
}
}
// End of Employee class.
# ***** END OF CLASSES ***** #
// Create a department:
$hr = new Department('Human Resources');
// Create employees:
$e1 = new Employee('Jane Doe');
$e2 = new Employee('John Doe');
// Add the employees to the department:
$hr->addEmployee($e1);
$hr->addEmployee($e2);
// Loop through the department:
echo "<h2>Department Employees</h2>";
foreach ($hr as $e) {
echo "<p>{$e->getName()}</p>";
}
// Delete the objects:
unset($hr, $e1, $e2);
?>
</body>
</html>