function tokenauth_install in Token authentication 5
Same name and namespace in other branches
- 6.2 tokenauth.install \tokenauth_install()
- 6 tokenauth.install \tokenauth_install()
- 7 tokenauth.install \tokenauth_install()
File
- ./
tokenauth.install, line 4
Code
function tokenauth_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {tokenauth_tokens} (\n uid int(11) NOT NULL,\n token varchar(50) NOT NULL,\n PRIMARY KEY (token),\n UNIQUE KEY (uid)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
}
// give an initial token to all
$sql = 'SELECT uid FROM {users}';
$result = db_query($sql);
while ($row = db_fetch_object($result)) {
$sql = "INSERT INTO {tokenauth_tokens} (uid, token) VALUES (%d, '%s')";
db_query($sql, $row->uid, user_password());
}
}