Kohana "One to many."
-
Once again, there's a problem, with one to many, there's empty lines in the table, what could be a problem, maybe someone's been in trouble?
For example: Controller:
$user->educations->user_personal_id = $id; $user->educations->faculty = "smp"; $user->educations->save();
Model:
class Model_User_personal extends ORM { protected $_has_many = array( 'educations' => array( 'model' => 'user_education', ), 'works' => array( 'model' => 'user_work', ), ); }
-
ORM has meths add(). Works like this:
$var = ORM::factory('your_model'); // передаём в модель данные $var->values($data_array); // сохраняем модель // при сохранении модель, по умолчанию, возвращает id вставленной строки try { $var->save()l } catch (ORM_Validation_Exception $e) { // do smth if error } // добавляем в выбранную модель те самые значения по связи $var->add('alias_name', $value);
/ where alias_name is a communication name and $value is a value