Creating Active Record Query - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Creating Active Record Query (/showthread.php?tid=52668) |
Creating Active Record Query - El Forum - 06-20-2012 [eluser]xtremer360[/eluser] I'm trying to figure out how I can come up with this query to match the active record functions. Code: +---------------+ +---------------+ +---------------+ Here's what I have so far. Code: /** Creating Active Record Query - El Forum - 06-20-2012 [eluser]Karman de Lange[/eluser] try Code: $this->db->select($this->titles_table.'.title_name'); just make sure you escape all correctley as the false sayd don't escape. L: Creating Active Record Query - El Forum - 06-20-2012 [eluser]CroNiX[/eluser] This part of the query should all be wrapped in double quotes. All of those single quotes within single quotes will break it: Code: $this->db->select("CASE WHEN c.contender_no = 0 THEN ‘Champion’ ELSE ‘Contender’ END as champion", FALSE); Creating Active Record Query - El Forum - 06-20-2012 [eluser]Karman de Lange[/eluser] corrected my answer.. had few mistakes.. probebly some left as well.. Creating Active Record Query - El Forum - 06-21-2012 [eluser]xtremer360[/eluser] I tried the following and have an invalid ut8 character string "champion" error Code: $this->db->select($this->titles_table.'.title_name'); Creating Active Record Query - El Forum - 06-21-2012 [eluser]Karman de Lange[/eluser] Try changing your qoutes from ‘’ to '' Creating Active Record Query - El Forum - 06-21-2012 [eluser]CroNiX[/eluser] The forum does that to single quotes. Most likely they are correct in the original code. Creating Active Record Query - El Forum - 06-21-2012 [eluser]xtremer360[/eluser] Is there a better way to write this query altogether? So it comes out like this? Code: [ 0 ] Title One name Creating Active Record Query - El Forum - 06-22-2012 [eluser]xtremer360[/eluser] Just wondering if there's a better way to create this query? |