![]() |
Using stored functions in Active Record - 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: Using stored functions in Active Record (/showthread.php?tid=4800) |
Using stored functions in Active Record - El Forum - 12-17-2007 [eluser]Alexxz[/eluser] How to use some DB functions in Active record? For example in MySQL, Code: UPDATE table SET value = 'new value', changed = NOW(); May be there is some dirty hack? I can't use php's time functions because i have a lot of servers with different time and one DB. Using stored functions in Active Record - El Forum - 12-17-2007 [eluser]Alexxz[/eluser] First type of hack I've found is use comments in unqoted field names like this Code: $set = array( Code: changed = NOW() /* = '', */ , value = 'new value' Using stored functions in Active Record - El Forum - 12-17-2007 [eluser]Alexxz[/eluser] Another solving method is to make own mysql driver, which improves CI mysqlex_driver.php Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); The utility and result parts of driver just inherit standard mysql driver. In configuration file $db['default']['dbdriver'] = "mysqlex"; Now i can write Code: $data = array(); Also I want to make 'LIMIT' restrictions for 'DELETE' statement. Using stored functions in Active Record - El Forum - 10-06-2008 [eluser]arslan ali[/eluser] i was looking for following query Code: SELECT * FROM (`banners`) WHERE banner_type = Menu AND status =Active AND start_date>=current_date() ORDER BY `id` desc After looking above post i tried this code and it worked magically for me. Code: $this->db->select(*); |