Esempio n. 1
0
 public function actionIndex()
 {
     $model = new Example();
     if (App::$request->post('Example')) {
         $model->load(App::$request->post('Example'));
     }
     return $this->render('site/index', ['model' => $model]);
 }
 public function insert()
 {
     $Exa = new Example();
     // Bu timestamps i bana sorun
     $Exa->timestamps = false;
     $Exa->name = "Ahmet";
     $Exa->lastname = "Mutlu";
     if ($Exa->save()) {
         $result = "insert tamam Reyiz!";
     } else {
         $result = "bir sıkıntı oldu!";
     }
     return \View::make("example", array("resultMessage" => $result));
 }
Esempio n. 3
0
 /**
  * model实例
  */
 public function actionModel()
 {
     $example = new Example();
     $example->showMessage();
     //获取所有记录
     $all = Example::all();
     foreach ($all as $item) {
         echo '<p>' . $item->name . '</p>';
     }
     echo '<br></br>';
     //获取一条记录
     $one = Example::find(1);
     echo '<p>' . $one->name . '</p>';
     echo '<br></br>';
     //条件查询
     $condition = array('name = ?', 'yang');
     $where = Example::find('all', array('conditions' => $condition));
     foreach ($where as $item) {
         echo '<p>' . $item->name . '</p>';
     }
     echo '<br></br>';
 }