/** * * @param UserHasModule $userHasModule * @return int id of the User inserted in base. False if it didn't work. */ public static function flush($userHasModule) { $userId = $userHasModule->getUserId(); $moduleId = $userHasModule->getModuleId(); $date = $userHasModule->getDate(); $mustPay = $userHasModule->getMustPay(); $receipt = $userHasModule->getReceipt(); $finalMark = $userHasModule->getFinalMark(); $hasFailed = $userHasModule->getHasFailed(); if ($userId > 0 && $moduleId > 0) { $sql = 'UPDATE user_has_module u SET ' . 'u.date = ?, ' . 'u.mustPay = ?, ' . 'u.receipt = ?, ' . 'u.finalMark = ?, ' . 'u.has_failed = ? ' . 'WHERE u.USER_id_user = ? AND u.MODULE_id_module=? '; $params = array('sbssbii', &$date, &$mustPay, &$receipt, &$finalMark, &$hasFailed, &$userId, &$moduleId); } else { $sql = 'INSERT INTO user_has_module ' . '(USER_id_user, MODULE_id_module, date, mustPay, receipt, ' . 'finalMark, has_failed) ' . 'VALUES (?, ?, ?, ?, ?, ?, ?)'; $params = array('sbssbii', &$userId, &$moduleId, &$date, &$mustPay, &$receipt, &$finalMark, &$hasFailed); } $idInsert = BaseSingleton::insertOrEdit($sql, $params); return $idInsert; }