我目前正在開發使用Codeigniter框架的MLM網站。Codeigniter識別每個第3個用戶註冊推薦
我現在正在註冊。我可以註冊成功推薦用戶
問題是每3註冊使用我的推薦用戶名/編號我需要運行另一個查詢,因爲在第一次和第二次推薦我賺200.在第三位用戶將引用我將只賺100
我該怎麼做Codeigniter?任何人這樣做?請幫助
我目前正在開發使用Codeigniter框架的MLM網站。Codeigniter識別每個第3個用戶註冊推薦
我現在正在註冊。我可以註冊成功推薦用戶
問題是每3註冊使用我的推薦用戶名/編號我需要運行另一個查詢,因爲在第一次和第二次推薦我賺200.在第三位用戶將引用我將只賺100
我該怎麼做Codeigniter?任何人這樣做?請幫助
讓我來看看這個 因此,假設您爲每個註冊發佈帖子,帖子將轉到類名註冊和註冊方法,並且引用ID作爲會話(refID)運行。此外,你有一個註冊模型,這是你應該做很可能:
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
}
}
}
現在,這是你的掛號模式將如何看待這樣的
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();
}
}
我希望這解釋了什麼是你真正想要的,並幫助你。如果您發現任何困難,請發表評論,並將其整理出來。
謝謝@sunday這真的幫助我:)這正是我需要的。再次感謝你.. –
歡迎你@Konjesh –
我可以再問一次嗎?我會發布新問題 –
Codeigniter與您的問題無關。您是否可以不計算針對推薦ID的註冊數量從引薦ID ='XXXXXX'的註冊中選擇計數(*);如果這個計數是2,那麼你知道它的第三次註冊? – TigerTiger
謝謝你的答覆兄弟:) –