• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SQL SELECT CASE in codeigniter

#1
[eluser]Unknown[/eluser]
I have the below query but I need to only select field_id_3 and field_id_4 if channel_id is 2, otherwise select field_id_9 and field_id_10

I've just started out doing sql queries with codeigniter so not sure how you would do a CASE SELECT with it.

Code:
<?php
        $this->EE->db->select('entry_id, channel_id, field_id_3, field_id_4, field_id_9, field_id_10', FALSE);
        $this->EE->db->from('exp_channel_data AS cd');
        $this->EE->db->where('entry_id', '{entry_id}');
        
        $query = $this->EE->db->get();
    ?>


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.