employees->add($michal); echo "Checking if Employee obejct updated: " . (($michal->company->getPrimaryKeyValue() == $epsi->getPrimaryKeyValue()) ? 'PASSED' : 'FAILED') . "\n"; $ok = false; foreach ($epsi->employees as $e) { $ok = $e->name = $michal->name; } echo "Checking if Company object updated: " . ($ok ? 'PASSED' : 'FAILED') . "\n"; $db->execute('SELECT * FROM employees WHERE id = 1 AND company_id = 1'); $ok = false; foreach ($db as $row) { $ok = true; } echo "Checking if database table updated: " . ($ok ? 'PASSED' : 'FAILED') . "\n"; $c = new Company(); $c->loadById(1); echo "Checking if new Company has new Employee: "; $ok = false; foreach ($c->employees as $e) { if ($e->name == $michal->name and $e->company_id == $michal->company_id) { $ok = true; } } echo ($ok ? 'PASSED' : 'FAILED') . "\n"; unset($c); $c = new Company(); $c->loadById(1); $e = new Employee(); $e->loadById(1); echo "Checking if created Employee belongs to Company: " . (($e->company->getPrimaryKeyValue() == $c->getPrimaryKeyValue()) ? 'PASSED' : 'FAILED') . "\n"; unset($c); unset($e); $e = new Employee(); $e->loadById(1); unset($e->company); $c = new Company(); $c->loadById(1); $ok = true; foreach ($c->employees as $employee) { $ok = false; } echo "Checking if unsetting Company successful: " . ($ok ? 'PASSED' : 'FAILED') . "\n"; unset($c); echo "Checking if Employee no longer belongs to Company: " . (($e->company === null) ? 'PASSED' : 'FAILED') . "\n"; unset($e); ?>