yii2删除数据有问题 [ 未指定版本 ]
public function actionDel($id = NULL)
{
$model = User::find()->where(['id' => $id])->one();
if (!$model->delete())
{
echo 2;die;
}
echo 1;die;
}
1.数据库的这条数据删除成功了,两个echo 都没有执行到。页面居然报错,求解?
2.请求地址:http://localhost/yii2/backend/web/index.php?r=user/del&id=36
3.报错信息:
PHP Fatal Error – yii\base\ErrorException
Call to a member function delete() on a non-object
请求地址:http://komeis.com/backend/web/index.php/quanwei/del?id=3
Database Exception – yii\db\Exception
SQLSTATE[42000]: Syntax error or access violation: 1142 DELETE command denied to user 'p22_handai'@'localhost' for table 'hd_quanwei'
The SQL being executed was: DELETE FROM hd_quanwei
WHERE id
=3
Error Info: Array
(
[0] => 42000
[1] => 1142
[2] => DELETE command denied to user 'p22_handai'@'localhost' for table 'hd_quanwei'
)
↵
Caused by: PDOException
SQLSTATE[42000]: Syntax error or access violation: 1142 DELETE command denied to user 'p22_handai'@'localhost' for table 'hd_quanwei'
in /home/p22/public_html/komeis.com/vendor/yiisoft/yii2/db/Command.php at line 768
共 4 个回答
-
vincent_kenfor 回答于 2015-05-21 14:11 举报
哥们,找出原因了没?我也遇到这种问题!!求分享~~
qq260101081 广州
最后登录:2017-09-25
在线时长:13小时20分
- 粉丝4
- 金钱40
- 威望10
- 积分270