var_dump($plan); echo '____------<br />'; echo '____recupere uniquement les champs price et maxRatio (et id qui est obligatoire) APRES modification'; $updatedPlan = $refPlanPdoManager->findAndModify($searchQuery, $updateCriteria, $fields, $options); var_dump($updatedPlan); echo '____------<br />'; $fields = NULL; $options = array('remove' => true); //supprimera au lieu de faire un update echo '____plan que l\'on supprime'; $result = $refPlanPdoManager->findAndModify($searchQuery, $updateCriteria, $fields, $options); var_dump($result); echo '____---------------------<br />'; $plan->setDownloadSpeed(5000); echo '____Reinsertion de l\'objet precedemment supprime'; $add = $refPlanPdoManager->create($plan); var_dump($add); echo '----------------------------------------<br />'; echo 'Utilisation du create, affiche true en cas de succes'; $newInsert = array('test' => TRUE); $createResult = $refPlanPdoManager->create($newInsert); var_dump($createResult); echo '----------------------------------------<br />'; echo 'Utilisation de l\'update, affiche true en cas de succes'; $criteria = array('test' => TRUE); $update = array('$set' => array('maxRatio' => (int) 500)); $updateResult = $refPlanPdoManager->update($criteria, $update); var_dump($updateResult); // true si l'update a réussi echo '----------------------------------------<br />'; echo 'Utilisation du remove, affiche true en cas de succes';
<?php /** * Created by PhpStorm. * User: Ken * Date: 10/06/14 * Time: 21:33 */ session_start(); $projectRoot = $_SERVER['DOCUMENT_ROOT'] . '/OwlEyes'; require_once $projectRoot . '/required.php'; $addPlanOK = false; //Traitement pour l'ajout du plan en bdd if (isset($_POST['add_plan'])) { $name = $_POST['name']; $price = $_POST['price']; $maxStorage = $_POST['maxStorage']; $dl = $_POST['downL']; $up = $_POST['upL']; $maxRatio = $_POST['maxRatio']; if (!empty($name) && !empty($price) && !empty($maxStorage)) { $refPlanManager = new RefPlanPdoManager(); $newPlan = array('name' => $name, 'price' => new MongoInt32($price), 'maxStorage' => new MongoInt32($maxStorage), 'downloadSpeed' => new MongoInt32($dl), 'uploadSpeed' => new MongoInt32($up), 'maxRatio' => new MongoInt32($maxRatio), 'state' => new MongoInt32(1)); $addPlan = $refPlanManager->create($newPlan); $addPlanOK = true; $message = 'Your plan has successfully inserted'; $_SESSION['addPlanMessage'] = $message; header('Location: ../pages/plan.php'); } }