grant_permissions Purpose: To work with the current txtSQL users
|
txtSQL >= 2.0.0 Beta |
void grant_permissions ( $action, $username, $password [, $newpass] )
This function allows for the manipulation of $user; it can either add a user, drop, or edit a user.
$action can be one of either add, edit, or drop.
If it is 'add', then $username will be the new user's name, and $password will be his/her password
If it is 'drop', then $username must be specified, and so does $password (password for this user).
If it is 'edit', then $username must be specified, along with $password, and $newpass. The new password would be
$newpass.
Note- If you are dropping, or editing a user, and the incorrect password is specified, OR when adding a user and the user already exists, then txtSQL will issue a warning and return false.
Note- You can never drop the user 'root'
Note- In txtSQL <= 2.2.0 Beta, setting an empty password would incorrectly save, do not set empty passwords before this.
<?php
// Add a user 'foo' with password 'bar'
$sql->grant_permissions('add', 'foo', 'bar')
?>
|
<?php
// Drop a user 'foo' whose password is 'bar'
$sql->grant_permissions('drop', 'foo', 'bar')
?>
|
<?php
// Edit a user 'foo' whose password is 'bar', and change the password to 'foobar'
$sql->grant_permissions('edit', 'foo', 'bar', 'foobar')
?>
|
|