'Language Reference'
User Functions
connect
disconnect
grant_permissions
getUsers
version
query_count
Database Functions
Data Manipulation Functions
Table Functions
Error Handling Functions
|
Usage |
void grant_permissions ( $action, $username, $password [, $newpass] ) |
Purpose |
To work with the current txtSQL users |
Availability |
txtSQL >= 2.0.0 Beta |
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.
Example 3: grant_permissions() to add user
| Copy to Clipboard |
<?php
// Add a user 'foo' with password 'bar'
$sql->grant_permissions('add', 'foo', 'bar')
?>
|
Example 4: grant_permissions() to drop user
| Copy to Clipboard |
<?php
// Drop a user 'foo' whose password is 'bar'
$sql->grant_permissions('drop', 'foo', 'bar')
?>
|
Example 5: grant_permissions() to edit user
| Copy to Clipboard |
<?php
// Edit a user 'foo' whose password is 'bar', and change the password to 'foobar'
$sql->grant_permissions('edit', 'foo', 'bar', 'foobar')
?>
|
User-Contributed Comments for: grant_permissions() |
|
FarazAli <Faraz87 at comcast dot net>
July 30, 2004, 11:19 pm
Passwords are automatically encrypted by txtSQL using the md5() hashing method, so there is no need to encrypt the password before hand.
|
|
|