public function actionDelete() { // 删除已有客户记录 $world = World::findOne("1"); $world->delete(); // 删除多个年龄大于20,性别为男(Male)的客户记录 //World::deleteAll('age > :age AND gender = :gender', [':age' => 20, ':gender' => 'M']); }
public function actionIndex() { World::updateAll(array('name' => 'Hello World!')); for ($i = 0; $i < 2; $i++) { $rnd = mt_rand(1, 10000); $result = World::findOne($rnd); } $result = World::findOne($result->id); return $result->name; }
/** * Finds the World model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return World the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = World::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }