本文整理汇总了PHP中common\models\User::deleteAll方法的典型用法代码示例。如果您正苦于以下问题:PHP User::deleteAll方法的具体用法?PHP User::deleteAll怎么用?PHP User::deleteAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\User
的用法示例。
在下文中一共展示了User::deleteAll方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _before
/**
* This method is called before each test method.
*
* @param \Codeception\Event\TestEvent $event
*/
public function _before($event)
{
// delete this signed up user
User::deleteAll(['email' => 'demo@example.com', 'username' => 'demo']);
// delete roles
Role::deleteAll();
}
示例2: actionDelete
public function actionDelete($id)
{
if (empty($user = User::findOne($id))) {
throw new \yii\web\NotFoundHttpException();
}
$count = User::deleteAll(['id' => $id]);
Invitation::deleteAll(['email' => $user->email, 'status' => Invitation::STATUS_SIGNUP]);
if ($count >= 1) {
$this->goBack();
}
}
示例3: actionDelete
public function actionDelete($id = 'none', $ids = 'none')
{
if ($id != 'none') {
if (User::find()->where(['id' => $id])->one()->delete()) {
Yii::$app->getSession()->addFlash('success', '<b>Пользователь успешно удален</b>');
return $this->actionIndex();
} else {
Yii::$app->getSession()->addFlash('success', '<b>Не удалось удалить пользователя</b>');
return $this->actionIndex();
}
}
if ($ids != 'none') {
$ids = explode(',', $ids);
if (User::deleteAll(['id' => $ids])) {
Yii::$app->getSession()->addFlash('success', '<b>Пользователи успешно удалены</b>');
return $this->actionIndex();
} else {
Yii::$app->getSession()->addFlash('success', '<b>Не удалось удалить пользователя</b>');
return $this->actionIndex();
}
}
}
示例4: actionUser
public function actionUser()
{
// create or change global admin user
User::deleteAll(['username' => 'admin']);
echo "\n Введите новый пароль администратора или пустую строку для выхода ";
$passw = trim(fgets(STDIN));
if (!$passw) {
echo "\n Действие прервано \n ";
exit(1);
}
$model = new User();
$model->username = 'admin';
$model->email = Yii::$app->params['adminEmail'];
$model->password = $passw;
$model->role = User::ROLE_ADMIN;
if ($model->save(false)) {
echo "\n Пароль администратора изменен \n ";
exit(0);
} else {
echo "\n Ошибка изменения пароля \n ";
exit(1);
}
}
示例5: actionDeleteUser
public function actionDeleteUser()
{
$selection = (array) Yii::$app->request->post('selection');
foreach ($selection as $id) {
if ($id != Yii::$app->params['adminId']) {
User::deleteAll(['id' => $id]);
Post::deleteAll(['user_id' => $id]);
PostNotification::deleteAll(['action_id' => $id]);
PostNotification::deleteAll(['receiver_id' => $id]);
Comment::deleteAll(['user_id' => $id]);
Like::deleteAll(['user_id' => $id]);
Message::deleteAll(['sender_id' => $id]);
Message::deleteAll(['receiver_id' => $id]);
Relationship::deleteAll(['user_id_1' => $id]);
Relationship::deleteAll(['user_id_2' => $id]);
RelationshipNotification::deleteAll(['action_id' => $id]);
RelationshipNotification::deleteAll(['receive_id' => $id]);
Schedule::deleteAll(['own_id' => $id]);
ScheduleNotification::deleteAll(['action_id' => $id]);
ScheduleNotification::deleteAll(['receiver_id' => $id]);
}
}
return $this->render('user-manage');
}
示例6: _after
/**
* This method is called after each cest class test method, even if test failed.
* @param \Codeception\Event\TestEvent $event
*/
public function _after($event)
{
User::deleteAll(['email' => 'tester.email@example.com', 'username' => 'tester']);
}
示例7: testSignup
/**
* @param AcceptanceTester $I
*/
public function testSignup(AcceptanceTester $I)
{
Option::up('allow_signup', '1');
$I->wantTo('ensure that signup works');
$signupPage = SignupPage::openBy($I);
$I->see('Register a new membership', 'p');
$I->amGoingTo('submit signup form with no data');
$signupPage->submit([]);
$I->expectTo('see validations error');
$I->see('Username cannot be blank.', '.help-block');
$I->see('Email cannot be blank.', '.help-block');
$I->see('Password cannot be blank.', '.help-block');
$I->amGoingTo('submit signup form with no correct email and password');
$signupPage->submit(['username' => 'newuser', 'email' => 'newuser.email', 'password' => 'pass']);
$I->expectTo('see that email and password are not correct.');
$I->dontSee('Username cannot be blank.', '.help-block');
$I->see('Email is not a valid email address.', '.help-block');
$I->see('Password should contain at least 6 characters.', '.help-block');
$I->amGoingTo('submit signup form with correct data');
$signupPage->submit(['username' => 'newuser', 'email' => 'newuser@writesdown.dev', 'password' => 'password']);
$I->expect('new user saved.');
$I->dontSee('Username cannot be blank.', '.help-block');
$I->dontSee('Email is not a valid email address.', '.help-block');
$I->dontSee('Password should contain at least 6 characters.', '.help-block');
User::deleteAll(['username' => 'newuser']);
Option::up('allow_signup', '0');
}
示例8: testCreate
/**
* @param AcceptanceTester $I
*/
public function testCreate(AcceptanceTester $I)
{
$I->wantTo('ensure that create user works');
$createPage = CreatePage::openBy($I);
$I->see('Add New User', 'h1');
$I->cantSeeElement('#user-role option[value="superadmin"]');
$I->amGoingTo('submit user form with no data');
$createPage->submit([]);
$I->expectTo('see validation errors');
$I->see('Username cannot be blank.', '.help-block');
$I->see('Email cannot be blank.', '.help-block');
$I->see('Password cannot be blank.', '.help-block');
$I->amGoingTo('submit user form with no correct email and password');
$createPage->submit(['username' => 'newuser', 'password' => 'newu', 'email' => 'newuser@email']);
$I->expectTo('see that given email is not correct');
$I->dontSee('Username cannot be blank.', '.help-block');
$I->see('Password should contain at least 6 characters.', '.help-block');
$I->see('Email is not a valid email address.', '.help-block');
$I->amGoingTo('submit user form with correct data');
$createPage->submit(['username' => 'newuser', 'password' => 'newuser', 'email' => 'newuser@writesdown.dev']);
$I->expect('new user saved');
$I->see('View User: newuser', 'h1');
User::deleteAll(['username' => 'newuser']);
}
示例9: actionDeleteajx
public function actionDeleteajx()
{
$post = Yii::$app->request->post();
$post['id'];
User::deleteAll(['id' => $post['id']]);
}
示例10: actionDeleteemployee
public function actionDeleteemployee()
{
$data = json_decode(file_get_contents("php://input"));
$query = User::deleteAll('sn=' . $data->sn);
if ($query) {
$response["status"] = 'success';
$response["message"] = 'Owner deleted successfully.';
//$response["data"]=(int)$model->id;
http_response_code(200);
header('Content-type: application/json');
echo json_encode($response, JSON_NUMERIC_CHECK);
}
}