Get related reseller based on hotel's reseller id [on hold]











up vote
0
down vote

favorite












Hello I have a reseller which connected multiple suppliers and each supplier has a multiple tickets and these ticket assigned and sale by hotel.



Each hotel assigned one reseller. Now I want to get hotel_id of which tickets assigned to hotels then I get assigned reseller to hotel.I done this task using below function but I want another solution which is simple with join.



public function  get_related_resellers_new($reseller_id) {

$this->primarydb->db->select("cod_id");
$this->primarydb->db->from("qr_codes");
$this->primarydb->db->where("reseller_id", $reseller_id);
$this->primarydb->db->where("cashier_type", "2");
$data = $this->primarydb->db->get();
$result = $data->result();

foreach ($result as $row) {
$supplier_ids = $row->cod_id;
}
$this->primarydb->db->select("mec_id");
$this->primarydb->db->from("pos_tickets");
$this->primarydb->db->where_in("museum_id", $supplier_ids);
$data = $this->primarydb->db->get();
// echo $this->primarydb->db->last_query();
// die;
$result_data = $data->result();
foreach ($result_data as $row) {
$ticket_ids = $row->mec_id;
}

$this->primarydb->db->select("hotel_id");
$this->primarydb->db->distinct("hotel_id");
$this->primarydb->db->from("pos_tickets");
$this->primarydb->db->where_in("mec_id", $ticket_ids);
$this->primarydb->db->where_in("museum_id", $supplier_ids);
$data = $this->primarydb->db->get();
// echo $this->primarydb->db->last_query();
// die;
$hotel_data = $data->result();
foreach ($hotel_data as $row) {
$hotel_ids = $row->hotel_id;
}

$this->primarydb->db->select("reseller_id");
$this->primarydb->db->from("qr_codes");
$this->primarydb->db->where_in("cod_id", $hotel_ids);
$this->primarydb->db->where("cashier_type", "1");
$data = $this->primarydb->db->get();
// echo $this->primarydb->db->last_query();
// die;
$reseller_id = $data->result();
foreach ($reseller_id as $row) {
$reseller_ids = $row->reseller_id;
}

$this->primarydb->db->select("reseller_name");
$this->primarydb->db->from("resellers");
$this->primarydb->db->where_in("reseller_id", $reseller_ids);
$data = $this->primarydb->db->get();
$related_reseller = $data->result();
echo "<pre>";print_r($related_reseller);
die;

}









share|improve this question







New contributor




Shahjad Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Toby Speight, Sᴀᴍ Onᴇᴌᴀ, vnp, Jamal 20 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Toby Speight, Sᴀᴍ Onᴇᴌᴀ, vnp, Jamal

If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1




    If you want a different solution, you should write that before posting it for review. Code Review is not the place to ask for help to write your code; it's to get constructive criticism of the code that you have written, and perhaps to suggest improvements.
    – Toby Speight
    yesterday















up vote
0
down vote

favorite












Hello I have a reseller which connected multiple suppliers and each supplier has a multiple tickets and these ticket assigned and sale by hotel.



Each hotel assigned one reseller. Now I want to get hotel_id of which tickets assigned to hotels then I get assigned reseller to hotel.I done this task using below function but I want another solution which is simple with join.



public function  get_related_resellers_new($reseller_id) {

$this->primarydb->db->select("cod_id");
$this->primarydb->db->from("qr_codes");
$this->primarydb->db->where("reseller_id", $reseller_id);
$this->primarydb->db->where("cashier_type", "2");
$data = $this->primarydb->db->get();
$result = $data->result();

foreach ($result as $row) {
$supplier_ids = $row->cod_id;
}
$this->primarydb->db->select("mec_id");
$this->primarydb->db->from("pos_tickets");
$this->primarydb->db->where_in("museum_id", $supplier_ids);
$data = $this->primarydb->db->get();
// echo $this->primarydb->db->last_query();
// die;
$result_data = $data->result();
foreach ($result_data as $row) {
$ticket_ids = $row->mec_id;
}

$this->primarydb->db->select("hotel_id");
$this->primarydb->db->distinct("hotel_id");
$this->primarydb->db->from("pos_tickets");
$this->primarydb->db->where_in("mec_id", $ticket_ids);
$this->primarydb->db->where_in("museum_id", $supplier_ids);
$data = $this->primarydb->db->get();
// echo $this->primarydb->db->last_query();
// die;
$hotel_data = $data->result();
foreach ($hotel_data as $row) {
$hotel_ids = $row->hotel_id;
}

$this->primarydb->db->select("reseller_id");
$this->primarydb->db->from("qr_codes");
$this->primarydb->db->where_in("cod_id", $hotel_ids);
$this->primarydb->db->where("cashier_type", "1");
$data = $this->primarydb->db->get();
// echo $this->primarydb->db->last_query();
// die;
$reseller_id = $data->result();
foreach ($reseller_id as $row) {
$reseller_ids = $row->reseller_id;
}

$this->primarydb->db->select("reseller_name");
$this->primarydb->db->from("resellers");
$this->primarydb->db->where_in("reseller_id", $reseller_ids);
$data = $this->primarydb->db->get();
$related_reseller = $data->result();
echo "<pre>";print_r($related_reseller);
die;

}









share|improve this question







New contributor




Shahjad Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Toby Speight, Sᴀᴍ Onᴇᴌᴀ, vnp, Jamal 20 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Toby Speight, Sᴀᴍ Onᴇᴌᴀ, vnp, Jamal

If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1




    If you want a different solution, you should write that before posting it for review. Code Review is not the place to ask for help to write your code; it's to get constructive criticism of the code that you have written, and perhaps to suggest improvements.
    – Toby Speight
    yesterday













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Hello I have a reseller which connected multiple suppliers and each supplier has a multiple tickets and these ticket assigned and sale by hotel.



Each hotel assigned one reseller. Now I want to get hotel_id of which tickets assigned to hotels then I get assigned reseller to hotel.I done this task using below function but I want another solution which is simple with join.



public function  get_related_resellers_new($reseller_id) {

$this->primarydb->db->select("cod_id");
$this->primarydb->db->from("qr_codes");
$this->primarydb->db->where("reseller_id", $reseller_id);
$this->primarydb->db->where("cashier_type", "2");
$data = $this->primarydb->db->get();
$result = $data->result();

foreach ($result as $row) {
$supplier_ids = $row->cod_id;
}
$this->primarydb->db->select("mec_id");
$this->primarydb->db->from("pos_tickets");
$this->primarydb->db->where_in("museum_id", $supplier_ids);
$data = $this->primarydb->db->get();
// echo $this->primarydb->db->last_query();
// die;
$result_data = $data->result();
foreach ($result_data as $row) {
$ticket_ids = $row->mec_id;
}

$this->primarydb->db->select("hotel_id");
$this->primarydb->db->distinct("hotel_id");
$this->primarydb->db->from("pos_tickets");
$this->primarydb->db->where_in("mec_id", $ticket_ids);
$this->primarydb->db->where_in("museum_id", $supplier_ids);
$data = $this->primarydb->db->get();
// echo $this->primarydb->db->last_query();
// die;
$hotel_data = $data->result();
foreach ($hotel_data as $row) {
$hotel_ids = $row->hotel_id;
}

$this->primarydb->db->select("reseller_id");
$this->primarydb->db->from("qr_codes");
$this->primarydb->db->where_in("cod_id", $hotel_ids);
$this->primarydb->db->where("cashier_type", "1");
$data = $this->primarydb->db->get();
// echo $this->primarydb->db->last_query();
// die;
$reseller_id = $data->result();
foreach ($reseller_id as $row) {
$reseller_ids = $row->reseller_id;
}

$this->primarydb->db->select("reseller_name");
$this->primarydb->db->from("resellers");
$this->primarydb->db->where_in("reseller_id", $reseller_ids);
$data = $this->primarydb->db->get();
$related_reseller = $data->result();
echo "<pre>";print_r($related_reseller);
die;

}









share|improve this question







New contributor




Shahjad Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











Hello I have a reseller which connected multiple suppliers and each supplier has a multiple tickets and these ticket assigned and sale by hotel.



Each hotel assigned one reseller. Now I want to get hotel_id of which tickets assigned to hotels then I get assigned reseller to hotel.I done this task using below function but I want another solution which is simple with join.



public function  get_related_resellers_new($reseller_id) {

$this->primarydb->db->select("cod_id");
$this->primarydb->db->from("qr_codes");
$this->primarydb->db->where("reseller_id", $reseller_id);
$this->primarydb->db->where("cashier_type", "2");
$data = $this->primarydb->db->get();
$result = $data->result();

foreach ($result as $row) {
$supplier_ids = $row->cod_id;
}
$this->primarydb->db->select("mec_id");
$this->primarydb->db->from("pos_tickets");
$this->primarydb->db->where_in("museum_id", $supplier_ids);
$data = $this->primarydb->db->get();
// echo $this->primarydb->db->last_query();
// die;
$result_data = $data->result();
foreach ($result_data as $row) {
$ticket_ids = $row->mec_id;
}

$this->primarydb->db->select("hotel_id");
$this->primarydb->db->distinct("hotel_id");
$this->primarydb->db->from("pos_tickets");
$this->primarydb->db->where_in("mec_id", $ticket_ids);
$this->primarydb->db->where_in("museum_id", $supplier_ids);
$data = $this->primarydb->db->get();
// echo $this->primarydb->db->last_query();
// die;
$hotel_data = $data->result();
foreach ($hotel_data as $row) {
$hotel_ids = $row->hotel_id;
}

$this->primarydb->db->select("reseller_id");
$this->primarydb->db->from("qr_codes");
$this->primarydb->db->where_in("cod_id", $hotel_ids);
$this->primarydb->db->where("cashier_type", "1");
$data = $this->primarydb->db->get();
// echo $this->primarydb->db->last_query();
// die;
$reseller_id = $data->result();
foreach ($reseller_id as $row) {
$reseller_ids = $row->reseller_id;
}

$this->primarydb->db->select("reseller_name");
$this->primarydb->db->from("resellers");
$this->primarydb->db->where_in("reseller_id", $reseller_ids);
$data = $this->primarydb->db->get();
$related_reseller = $data->result();
echo "<pre>";print_r($related_reseller);
die;

}






php codeigniter






share|improve this question







New contributor




Shahjad Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Shahjad Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Shahjad Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









Shahjad Ahmed

1




1




New contributor




Shahjad Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Shahjad Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Shahjad Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as off-topic by Toby Speight, Sᴀᴍ Onᴇᴌᴀ, vnp, Jamal 20 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Toby Speight, Sᴀᴍ Onᴇᴌᴀ, vnp, Jamal

If this question can be reworded to fit the rules in the help center, please edit the question.




put on hold as off-topic by Toby Speight, Sᴀᴍ Onᴇᴌᴀ, vnp, Jamal 20 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Toby Speight, Sᴀᴍ Onᴇᴌᴀ, vnp, Jamal

If this question can be reworded to fit the rules in the help center, please edit the question.








  • 1




    If you want a different solution, you should write that before posting it for review. Code Review is not the place to ask for help to write your code; it's to get constructive criticism of the code that you have written, and perhaps to suggest improvements.
    – Toby Speight
    yesterday














  • 1




    If you want a different solution, you should write that before posting it for review. Code Review is not the place to ask for help to write your code; it's to get constructive criticism of the code that you have written, and perhaps to suggest improvements.
    – Toby Speight
    yesterday








1




1




If you want a different solution, you should write that before posting it for review. Code Review is not the place to ask for help to write your code; it's to get constructive criticism of the code that you have written, and perhaps to suggest improvements.
– Toby Speight
yesterday




If you want a different solution, you should write that before posting it for review. Code Review is not the place to ask for help to write your code; it's to get constructive criticism of the code that you have written, and perhaps to suggest improvements.
– Toby Speight
yesterday















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

List directoties down one level, excluding some named directories and files

list processes belonging to a network namespace

list systemd RuntimeDirectory mounts