/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new ABenchmark();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['ABenchmark'])) {
         $model->attributes = $_POST['ABenchmark'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
示例#2
0
 /**
  * @param string $url The URL to benchmark
  * @param string $route The route to benchmark
  * @param string $params The parameters to pass to the route or URL, these can be a comma separated list of attribute:value
  *
  */
 public function actionAdd($url = null, $route = null, $params = null)
 {
     if ($url === null && $route === null) {
         throw new CException("Either a URL or a route is required!");
     }
     $model = new ABenchmark();
     $model->url = $url;
     $model->route = $route;
     if ($route !== null && $params !== null) {
         $model->params = array();
         foreach (explode(",", $params) as $param) {
             $param = explode(":", $param);
             $model->params[$param[0]] = $param[1];
         }
     }
     if ($model->save()) {
         echo "Benchmark Added\n";
     } else {
         echo "Failed to save benchmark\n";
         print_r($model->getErrors());
     }
 }