$school = new Schools();
foreach($_POST as $k=>$v) {
$school->$k = $v;
}
if ($school->create()) {
$this->flash->success('ok');
} else {
$this->flash->success('exists');
}
This works OK.
BUT
$school = new Schools();
// foreach($_POST as $k=>$v) {
// $school->$k = $v;
// }
if ($school->create($_POST)) {
$this->flash->success('ok');
} else {
$this->flash->success('exists');
}
will update the record already exists without check.