php

Delete from DB OOP

//delete from DB
<?php
    public function deleteUser($firstname, $lastname){
        $sql = 'DELETE FROM users WHERE firstname = ? && lastname = ?';
        $stmt = $this->connect()->prepare($sql);
        $stmt->execute([$firstname, $lastname]);
    }

//in index.php
$deleteUser = new test();
$deleteUser->deleteUser('John','Doe');

DELETE

OOP

DB

Was this helpful?