本文整理汇总了PHP中app\models\User::deleteAll方法的典型用法代码示例。如果您正苦于以下问题:PHP User::deleteAll方法的具体用法?PHP User::deleteAll怎么用?PHP User::deleteAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::deleteAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
{
// $result = User::find()->all();
// $last_num = count($result)-1;
//第一种方法:删除数据库中最后一行数据
//$result[$last_num]->delete();
//第二种方法:删除数据库中Id大于2的
User::deleteAll('id>:id', array(':id' => 2));
}
示例3: actionDelete
public function actionDelete($id)
{
$result = User::deleteAll("id = {$id}");
if (!$result) {
Yii::$app->session->setFlash('delete_error', 'Error user delete.');
Yii::error('Error user delete');
}
$url = Yii::$app->urlManager->createUrl('admin/user/index');
$this->redirect($url);
}
示例4: actionDelete
/**
* Deletes an existing User model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id = null, array $ids = null)
{
$ok_message = false;
if (!$id && $ids) {
// multiple
if (User::deleteAll(['id' => $ids])) {
$ok_message = __('Items have been deleted successfully.');
}
} elseif ($this->findModel($id)->delete()) {
// single
$ok_message = __('Item has been deleted successfully.');
}
if ($ok_message) {
Yii::$app->session->setFlash('success', $ok_message);
// if ($referrer = Yii::$app->request->referrer) {
// return $this->redirect($referrer);
// }
}
return $this->redirect(['index']);
}
示例5: actionDeleteall
public function actionDeleteall()
{
$role = UserRoleDetector::getUserRole();
Yii::$app->response->format = Response::FORMAT_JSON;
if ($role != 3 && $role != 4) {
echo json_encode(array('status' => 0, 'error_code' => Codes::$UNAUTHORIZED, 'errors' => StatusCodeMessage::$UNAUTHORIZED), JSON_PRETTY_PRINT);
} else {
$ids = json_decode($_REQUEST['ids']);
$stringIds = implode(",", $ids);
if (User::deleteAll('user_id IN (' . $stringIds . ')')) {
echo json_encode(array('status' => 1, 'code' => 200, 'data' => 'deleted'), JSON_PRETTY_PRINT);
} else {
echo json_encode(array('status' => 0, 'error_code' => Codes::$BAD_REQUEST), JSON_PRETTY_PRINT);
}
}
}
示例6: actionDeleteUser
public function actionDeleteUser()
{
if ($this->isDeleteAllowed()) {
if (Yii::$app->request->get()) {
User::deleteAll('id = ' . Yii::$app->request->get()['id']);
/*return $this->render('user_list');*/
return $this->redirect(['security/user-management']);
}
return $this->render('user_list');
} else {
echo "You don't have access here";
die;
}
}
示例7: actionClear
/**
* Delete all Users from the database.
*/
public function actionClear()
{
if (User::deleteAll()) {
echo "All users deleted.\n";
}
}