Codeigniter/PHP:使用 TankAuth 批量创建用户
我有兴趣使用 TankAuth for CodeIgniter 批量创建批量用户/密码。我在 CI 论坛上问了这个问题,但没有得到回复:
http://codeigniter.com/forums/viewthread/110993/P330/# 837327
除了我的帖子作为第三个结果和一堆不相关的网站之外,谷歌搜索并没有出现太多。
http:// www.google.com/search?sourceid=chrome&ie=UTF-8&q=create+batch+users+tankauth
有人使用递归算法成功完成此操作吗?如果是这样,您可以发布一些代码来让我走上正确的道路吗?谢谢!
软件版本:
CI 1.7.3
TankAuth 1.0.7
PHP 5.x
编辑2/15:
以防万一有人正在寻找解决方案,这里有一个与我基本相同的功能使用(还有一些其他参数,但这应该可以帮助您继续):
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>";
}
}
只需从控制器 ping batchReg() 即可将其付诸实践!
I am interested in creating bulk users/passwords in a batch using TankAuth for CodeIgniter. I asked this question on the CI forums but got no responses:
http://codeigniter.com/forums/viewthread/110993/P330/#837327
Google searches don't turn up much besides my thread as the third result and a bunch of unrelated sites.
http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=create+batch+users+tankauth
Has anyone successfully done this using a recursion algorithm? If so, can you post some code to get me going on the right path? Thanks!
Versions of software:
CI 1.7.3
TankAuth 1.0.7
PHP 5.x
EDIT 2/15:
Just in case anyone is looking for a solution to this, here's a function that is basically the same one I used (there were some other parameters, but this should get you going):
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>";
}
}
Just ping batchReg() from the controller to put it into action!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说,听起来像是一个简单的循环操作
(无论来源如何)以可迭代的形式(如数组
$user_list
)获取您的用户名,我们会说它看起来像这样
然后创建一个简单的循环例程来处理新注册,将密码存储回数组中,这样您将获得登录名、新(随机)密码和电子邮件的完整列表。
最后,您的
$user_list
包含您用户的所有新密码。Sounds like a simple loop operation to me
somehow (whatever the source) get your usernames in a iterable form like an array
$user_list
we'll say it looks like this
Then create a simple looping routine to process the new registrations, storing the password back into the array, so you will then have a complete list of logins, new (randomized) passwords and emails.
Then at the end your
$user_list
contains all the new passwords for your users.