[英]Codeigniter Identify Every 3rd user Registration referral
I'm currently developing an MLM Website using Codeigniter Framework. 我目前正在使用Codeigniter Framework开发一个MLM网站。
And I am working on registration now. 我现在正在注册。 I can register successful with referral user 我可以向推荐用户注册成功
The problem is every 3 registration using my referral username/id i need to run another query because in 1st and 2nd referral I earned 200. and in 3rd user will refer i will only earn 100. 问题是每3个使用我的推荐用户名/ ID进行注册,我都需要运行另一个查询,因为在第一和第二推荐中我赚了200。在第三用户中,我只能赚100。
How can I do that in Codeigniter? 如何在Codeigniter中做到这一点? anyone done this? 有人这样做吗? please help 请帮忙
Let me throw some light on this So lets say you make a post for every registration, the post goes to a class names registration and a register method, and the referral id runs as a session (refID). 让我对此进行一些说明。因此,可以说您为每个注册创建了一个帖子,该帖子转到了一个类名注册和一个register方法,并且引用id作为会话(refID)运行。 Also, you have a registration model, this is what you should likely do: 另外,您有一个注册模型,这可能是您应该做的:
class registration extends CI_Controller{
function __construct(){
parent::__construct();
$this->load->model('registration_model');
}
//ensue to check for the existence of the refID session before processing
function register(){
if($_POST){
//first run form validation
//you should have auto loaded the form_validation library
//and created a rules function that carries the form rules
$rules = $this->rules();
$this->form_validation->set_rules($rules);
if($this->form_validation->run() == FALSE){
//load view here
}else{
//first, get post data
//then get the number of registration done by user using the refID
//if registration is greater than 2, set earnings to 100
//set earnings to 200
//then proceed to insert registration and do something else
//get post data, assumed post data
$name = $this->input->post('name');
$email = $this->input->post('email');
//get number of registrations
$numOfRegs = $this->registration_model->getRegByRefID();
//set the earnings from the number of registrations
$earning = $numOfRegs < 3 ? 200 : 100;
//please note that the for $numOfRegs = 4, $earnings will be 100, as this was not specified in the question
//at this point, you have set the earnings, you can proceed to do whatever you wish to do, perhaps insert the records
//please note that this code block just explains what you can likely do after setting the earnings
$insert = array(
"name" => $name,
"email" => $email,
"earning" => $earning
);
$this->registration_model->insert($array);
// then do anything else
}
}else{
//load view here
}
}
}
Now this is how your registration model will look like this 现在这就是您的注册模型的样子
class Registration_model extends CI_Model{
function __construct(){
parent::__construct();
}
function getRegByRefID(){
$refID = $this->session->refID;
return $this->db->get_where('mydb', array("refID" => $refID))->num_rows();
}
}
I hope this explains what you really wants, and helps you. 我希望这可以解释您的真正需求并为您提供帮助。 If you find any difficulty, kindly comment and lets sort it out. 如果发现任何困难,请发表评论并进行整理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.