Exemple #1
0
 /**
  * Finish an experiment for a given identity
  *
  * Mark a given experiment (be it multivar or not) as complete for a given identity.
  * If a matching treatment does not exist, the call should be ignored, rather than 
  * creating a new treatment.
  *
  * @param string|Scenario_Experiment $experiment 
  * @param Scenario_Identity $id 
  */
 public function FinishExperiment($experiment, Scenario_Identity $id)
 {
     if (is_string($experiment)) {
         $experiment = $this->GetExperimentByName($experiment);
     }
     if ($experiment->isMultiVar()) {
         $children = array();
         foreach ($experiment->getChildren() as $child) {
             $children[] = $child->getRowId();
         }
         $children = implode(',', $children);
         $result = $this->getDbAdapter()->update($this->usersTreatmentsTable, array('completed' => 1), array($this->quote('identity = ?', $id->getDbIdent()), sprintf('experiment_id IN (%s)', $children)));
     } else {
         $result = $this->getDbAdapter()->update($this->usersTreatmentsTable, array('completed' => 1), array($this->quote('identity = ?', $id->getDbIdent()), $this->quote('experiment_id = ?', $experiment->getRowId())));
     }
     return $result > 0;
 }
Exemple #2
0
 /**
  * Finish an experiment for a given identity
  *
  * Mark a given experiment (be it multivar or not) as complete for a given identity.
  * If a matching treatment does not exist, the call should be ignored, rather than 
  * creating a new treatment.
  *
  * @param string|Scenario_Experiment $experiment 
  * @param Scenario_Identity $id 
  */
 public function FinishExperiment($experiment, Scenario_Identity $id)
 {
     if (is_string($experiment)) {
         $experiment = $this->GetExperimentByName($experiment);
     }
     if ($experiment->isMultiVar()) {
         $children = array();
         foreach ($experiment->getChildren() as $child) {
             $children[] = $child->getRowId();
         }
         $children = implode(',', $children);
         $sql = "UPDATE {$this->usersTreatmentsTable} SET completed = ? \n                  WHERE identity = ? AND experiment_id IN ({$children})";
         $result = $this->prepare($sql, array(1, $id->getDbIdent()));
     } else {
         $sql = "UPDATE {$this->usersTreatmentsTable} SET completed = ?\n                  WHERE identity = ? AND experiment_id = ?";
         $result = $this->prepare($sql, array(1, $id->getDbIdent(), $experiment->getRowId()));
     }
     return $result->rowCount() > 0;
 }