Beispiel #1
0
 /**
  * Get an existing treatment.
  *
  * Retrieve the current treatment in use by a Experiment/id combo. Returns null if not yet in use.
  *
  * @param Scenario_Experiment $experiment
  * @param Scenario_Identity $id
  * @return Scenario_Treatment|null
  */
 public function GetTreatmentForIdentity(Scenario_Experiment $experiment, Scenario_Identity $id)
 {
     if ($experiment->getRowID() === null) {
         $parent = $experiment->getParent();
         $experiment_id = $this->GetExperimentID($experiment->getExperimentID(), $parent === null ? null : $parent->getRowID());
     } else {
         $experiment_id = $experiment->getRowID();
     }
     if ($experiment_id == null) {
         return null;
     }
     $query = $this->getDbAdapter()->select()->from($this->usersTreatmentsTable)->joinLeft($this->treatmentsTable, $this->treatmentsTable . '.id = ' . $this->usersTreatmentsTable . '.treatment_id')->where('identity = ?', $id->getDbIdent())->where($this->treatmentsTable . '.experiment_id = ?', $experiment_id);
     $result = $this->getDbAdapter()->fetchRow($query);
     if ($result === false) {
         return null;
     }
     /**
      * @see Scenario_Treatment
      */
     require_once 'Scenario/Treatment.php';
     return new Scenario_Treatment($result['name'], $experiment, $result['id']);
 }