Just as you can add and edit users, patUser() also comes with - obviously! - a deleteUser() method. This method accepts, as input, a user ID, and removes the corresponding user record from the database. If no user ID is provided, the currently logged-in user's ID is used instead. The following example demonstrates:
<?php
// include classes
include("../include/patDbc.php");
include("../include/patUser.php");
// initialize database layer
$db = new patMySqlDbc("localhost", "db211", "us111", "secret");
// initialize patUser
$u = new patUser(true);
// connect patUser to database
$u->setAuthDbc($db);
// set table
$u->setAuthTable("users");
// delete user
$u->deleteUser( array ("uid" => 15) );
?>
Similarly, the deleteGroup() method allows you to remove a group from the
group database.
<?php
// include classes
include("../include/patDbc.php");
include("../include/patUser.php");
// initialize database layer
$db = new patMySqlDbc("localhost", "db211", "us111", "secret");
// initialize patUser
$u = new patUser(true);
// connect patUser to database
$u->setAuthDbc($db);
// set table
$u->setGroupTable("groups");
// delete group
$u->deleteGroup( array("gid" => 4) );
?>