function saveCalendarBusinessHours($aData) { $CalendarUid = $aData['CALENDAR_UID']; $CalendarBusinessDay = $aData['CALENDAR_BUSINESS_DAY']; $CalendarBusinessStart = $aData['CALENDAR_BUSINESS_START']; $CalendarBusinessEnd = $aData['CALENDAR_BUSINESS_END']; //if exists the row in the database propel will update it, otherwise will insert. $tr = CalendarBusinessHoursPeer::retrieveByPK($CalendarUid, $CalendarBusinessDay, $CalendarBusinessStart, $CalendarBusinessEnd); if (!(is_object($tr) && get_class($tr) == 'CalendarBusinessHours')) { $tr = new CalendarBusinessHours(); } $tr->setCalendarUid($CalendarUid); $tr->setCalendarBusinessDay($CalendarBusinessDay); $tr->setCalendarBusinessStart($CalendarBusinessStart); $tr->setCalendarBusinessEnd($CalendarBusinessEnd); if ($tr->validate()) { // we save it, since we get no validation errors, or do whatever else you like. $res = $tr->save(); } else { // Something went wrong. We can now get the validationFailures and handle them. $msg = $CalendarBusinessDay . '<hr/>'; $validationFailuresArray = $tr->getValidationFailures(); foreach ($validationFailuresArray as $objValidationFailure) { $msg .= $objValidationFailure->getMessage() . "<br/>"; } //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); G::SendTemporalMessage($msg); } //return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => ''); //to do: uniform coderror structures for all classes //if ( $res['codError'] < 0 ) { // G::SendMessageText ( $res['message'] , 'error' ); //} }