![]() |
ActiveRecord: dbprefix on tables inside MySQL functions - 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: ActiveRecord: dbprefix on tables inside MySQL functions (/showthread.php?tid=19554) |
ActiveRecord: dbprefix on tables inside MySQL functions - El Forum - 06-11-2009 [eluser]Unknown[/eluser] I have dbprefix set to TEST_ and a select statement like the following: DATE_FORMAT(table.date, '%e-%c-%Y') as dk_date table names inside both DATE_FORMAT and TIME_FORMAT doesn't get prefixed with dbprefix. ActiveRecord: dbprefix on tables inside MySQL functions - El Forum - 06-11-2009 [eluser]Phil Sturgeon[/eluser] Sadly, although the ActiveRecord class is brilliant, it is not magic. You need to tell it the prefix if you are using normal queries, so you will have to put: Code: $this->db->select('DATE_FORMAT('.$this->db->dbprefix('table').'.date, "%e-%c-%Y") as dk_date'); I actually forgot the exact useage of db prefix, so guess how I found out how to use it... I did this! ;-P ActiveRecord: dbprefix on tables inside MySQL functions - El Forum - 06-11-2009 [eluser]Dam1an[/eluser] Ah, good ol' lmgtfy to the rescue yet again Someone should rerally build a let-me-search-the-ci-user-guide-and-forums-for-you app as well ![]() ActiveRecord: dbprefix on tables inside MySQL functions - El Forum - 06-11-2009 [eluser]Phil Sturgeon[/eluser] I thought you'd like that. ActiveRecord: dbprefix on tables inside MySQL functions - El Forum - 06-11-2009 [eluser]Unknown[/eluser] . |