mysqli删除查询返回布尔值false

时间:2016-08-20 02:37:40

标签: php oop mysqli

我正在观看教程我正在尝试删除特定部分按ID,我收到错误处理请求,这是我的模型中的错误异常,如果我var_damp我的查询它返回布尔值假idk为什么这不是工作

模型

public function deletesec($id)
{
    // Delete a specific section.
    $query = "DELETE * FROM $this->tablename WHERE id = '$id'";

    if (!$sqli = mysqli_query($this->cxn->connect(),$query)) {          
        var_dump($sqli);
        throw new Exception("Error Processing Request");            
    } else
        echo "Done";
}

控制器

try
{
    //Display all data.
    require_once '../model/cone.php';
    require_once '../model/display.php';
    $display = new Display("sections");
    $data    = $display->getSections();

    //Delete a specific section By Id.  
    if(isset($_GET['deleteid']))
    {
        $id     = $_GET['deleteid'];
        require_once '../model/dsections.php';
        $delete = new Dsections("sections");
        $delete->deletesec($id);
    }

    //my view.
    require_once '../view/vsections.php';
}

1 个答案:

答案 0 :(得分:0)

删除*

更改查询
$query = "DELETE  FROM $this->tablename WHERE id = '$id'";

另请查看删除语句语法http://dev.mysql.com/doc/refman/5.7/en/delete.html