/** * * @param <type> $id the user id to modify the values here * @param <type> $userInstanceNewValues the new values of the user info * that are in the user instance */ public function modifyUserInfo($id, $userInstanceNewValues) { $connector = new DBConnector(); $connection = $connector->createConnection(); $userId = $userInstanceNewValues->getId(); $gender = $userInstanceNewValues->gender; $maritalStatus = $userInstanceNewValues->maritalSt; $studies = $userInstanceNewValues->studies; $institutionName = $userInstanceNewValues->getInstitutionName(); $country = $userInstanceNewValues->getCountry(); $religion = $userInstanceNewValues->getReligion(); $query = "UPDATE userinfo set gender='" . $gender . "', maritalSt='" . $maritalStatus . "', studies='" . $studies . "' , InstitutionName='" . $institutionName . "' , currentLocation='" . $country . "' , religion='" . $religion . "' where FK_users=" . $userId; mysql_query($query) or die("Error in query modifying user info : {$query}. " . mysql_error() . " and the user id is" . $id); mysql_close($connection); }
/** * Effectue la serialisation de la commande dans la base de données * en utilisant une transaction afin de valider la serialisation * complete de la commande. * * @param <type> $form formulaire de la carte de credit du client * @param <type> $user utilisateur de la session associé au client * @param <type> $address adresse du client * @param <type> $shoppingCart panier de l'utilisateur */ private function registerOrder($form, $user, $address, $shoppingCart) { $conn = Doctrine_Core::getTable('IStoreOrder')->getConnection(); $conn->beginTransaction(); try { // on sauvegarde la carte de credit $creditCard = $form->save(); // on cree une commande en base de données. $order = new IStoreOrder(); $order->setDate(date('Y-m-d')); $order->setCreditCardId($creditCard->getId()); $order->setUserId($user->getId()); $order->save(); // on sauvegarde une copie de l'adresse du client // pour la commande. $orderAddress = new IStoreAddress(); $orderAddress->setStreet($address->getStreet()); $orderAddress->setCity($address->getCity()); $orderAddress->setZipcode($address->getZipcode()); $orderAddress->setCountry($address->getCountry()); $orderAddress->setOrderId($order->getId()); $orderAddress->save(); $order->setAddressId($orderAddress->getId()); $order->save(); // on sauvegarde chaque ligne de la commande foreach ($shoppingCart->getItems() as $item) { $orderLine = new IStoreOrderLine(); $orderLine->setItemId($item->getId()); $orderLine->setOrderId($order->getId()); $orderLine->setQuantity($item->getQuantity()); $orderLine->save(); } $conn->commit(); return $order; } catch (Exception $e) { $conn->rollBack(); throw $e; } }