Creating Batch Users in TankAuth (CodeIgniter)

As detailed in this Stack Overflow request, I had the need to convert an existing database of users/passwords (stored in plaintext) to our new authentication library driven by CI and TankAuth. User jondavidjohn got me on the right track, and here’s the code I ended up writing to submit to Stack Overflow for sample use:

[php]
function batchReg()
{
$this->load->model(‘mymodel’);

// connect to the database
$this->mymodel->dbconnect();

// build it
$query = "SELECT user, email, pass from newusers ORDER BY user ASC";

// ship it
$result = mysql_query($query);

// loop it
while ($row = mysql_fetch_array($result))
{
$data = $this->tank_auth->create_user($row[‘user’], $row[’email’], $row[‘pass’], FALSE);
print_r($data);
echo "<p>";
}

}
[/php]
Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *