![]() |
SQL function - 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: SQL function (/showthread.php?tid=6457) |
SQL function - El Forum - 02-28-2008 [eluser]piker[/eluser] Can I use SQL functions in query selection? Code: $query = $this->db->query("SELECT path,title, SUBSTR( body, 1, 50 ) FROM news "); Is it other way to resolve the problem? Have nice day piker SQL function - El Forum - 02-28-2008 [eluser]xwero[/eluser] You should be able to run that query, which error are you getting? To debug you can add Code: echo $this->db->last_query(); SQL function - El Forum - 02-29-2008 [eluser]piker[/eluser] Solution I made in VIEW something like this: Code: <?php foreach ($adam as $key): ?> You ask me for an error information. If in controller is something like this: Code: line1 $query = $this->db->query("SELECT title, SUBSTR( body, 1, 50 ) FROM newsy"); CI give us that error information: Quote:A PHP Error was encountered I'am using XAMPP under WinXP in standard configuration. SQL function - El Forum - 02-29-2008 [eluser]xwero[/eluser] you have to use an alias for the field in the function and it can't be the same as the field name. Code: $query = $this->db->query("SELECT title, SUBSTR( body, 1, 50 ) as short FROM newsy"); |