Question about ORM(Update) - 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: Question about ORM(Update) (/showthread.php?tid=51839) |
Question about ORM(Update) - El Forum - 05-20-2012 [eluser]InterMedio[/eluser] Hello everybody. I wrote model t_activity.php Code: class T_activity extends CI_Model { Code: $current_ = time(); This working, when I put this sql request in controller. But I want store this sql query in model. Anybody can tell me, where can be error or how correct write this request in ORM syntax? Thanks all. Question about ORM(Update) - El Forum - 05-20-2012 [eluser]WanWizard[/eluser] Which ORM? Question about ORM(Update) - El Forum - 05-21-2012 [eluser]InterMedio[/eluser] It is native ORM for the CodeIgniter. So, just active record. Question about ORM(Update) - El Forum - 05-21-2012 [eluser]WanWizard[/eluser] Codeigniter doesn't have a native ORM, it has a query builder (called active record in versions up to 2.1.0). You need a syntax like Code: $this->db->where('SUBSTRING_INDEX(SUBSTRING_INDEX(user_data, '\"', 4) , '\"', -1)', $user_id, FALSE); Question about ORM(Update) - El Forum - 05-21-2012 [eluser]InterMedio[/eluser] [quote author="WanWizard" date="1337591018"]Codeigniter doesn't have a native ORM, it has a query builder (called active record in versions up to 2.1.0). You need a syntax like Code: $this->db->where('SUBSTRING_INDEX(SUBSTRING_INDEX(user_data, '\"', 4) , '\"', -1)', $user_id, FALSE); Probably I mistaken and gave incorrect name to query builder. Agree. Thank you for the advice. I'll try and describe about results. Question about ORM(Update) - El Forum - 05-21-2012 [eluser]InterMedio[/eluser] [quote author="WanWizard" date="1337591018"]Codeigniter doesn't have a native ORM, it has a query builder (called active record in versions up to 2.1.0). You need a syntax like Code: $this->db->where('SUBSTRING_INDEX(SUBSTRING_INDEX(user_data, '\"', 4) , '\"', -1)', $user_id, FALSE); This query doesn't work. Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2 AND `id` = '2'' at line 1 Code: UPDATE `users` SET `location` = 'Profile' WHERE SUBSTRING_INDEX(SUBSTRING_INDEX(user_data, '"', 4) , '"', -1)2 AND `id` = '2' I also used this syntax Code: $this->db->where("SUBSTRING_INDEX(SUBSTRING_INDEX(user_data, '\"', 4) , '\"', -1)", $user_id, FALSE); |