src/Database/Model.php
public function deleteById($id) : int
    {
        $sql = 'DELETE FROM `' . $this->table . '` WHERE ';

        // Assign ids
        if (is_array($id)) {
            $i = 0;
            foreach ($id as $_id) {
                if ($i === 0) {
                    $sql .= ' id=:id' . $i;
                } else {
                    $sql .= ' OR id=:id' . $i;
                }
                $i++;
            }
            $query = $this->pdo->prepare($sql);
            for ($j = 0; $j < 0; $j++) {
                $query->bindParam(':id' . $j, $id[$j]);
            }
        } else {
            $sql .= 'id=:id';
            $query = $this->pdo->prepare($sql);
            $query->bindParam(':id', $id);
        }

        $query->execute();

        return $query->rowCount();
    }
public function deleteById($id) : int
    {
        $sql = 'DELETE FROM `' . $this->table . '` WHERE ';

        // Assign ids
        if (is_array($id)) {
            $i = 0;
            foreach ($id as $_id) {
                if ($i === 0) {
                    $sql .= ' id=:id' . $i;
                } else {
                    $sql .= ' OR id=:id' . $i;
                }
                $i++;
            }
            $query = $this->pdo->prepare($sql);
            for ($j = 0; $j < 0; $j++) {
                $query->bindParam(':id' . $j, $id[$j]);
            }
        } else {
            $sql .= 'id=:id';
            $query = $this->pdo->prepare($sql);
            $query->bindParam(':id', $id);
        }

        $query->execute();

        return $query->rowCount();
    }
public function deleteById ( $ id ) : int { $ sql = 'DELETE FROM `' . $ this -> table . '` WHERE ' ; // Assign ids if ( is_array ( $ id ) ) { $ i = 0 ; foreach ( $ id as $ _id ) { if ( $ i === 0 ) { $ sql .= ' id=:id' . $ i ; } else { $ sql .= ' OR id=:id' . $ i ; } $ i ++ ; } $ query = $ this -> pdo -> prepare ( $ sql ) ; for ( $ j = 0 ; $ j < 0 ; $ j ++ ) { $ query -> bindParam ( ':id' . $ j , $ id [ $ j ] ) ; } } else { $ sql .= 'id=:id' ; $ query = $ this -> pdo -> prepare ( $ sql ) ; $ query -> bindParam ( ':id' , $ id ) ; } $ query -> execute ( ) ; return $ query -> rowCount ( ) ; }
Run a DELETE query
@param string|array $id Id(s) to delete
@return int Return affected rows
@since 1.1.4
Run a DELETE query