![]() |
Need help converting SQL to ActiveRecord? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Need help converting SQL to ActiveRecord? (/showthread.php?tid=88011) |
Need help converting SQL to ActiveRecord? - KanitkarRana - 07-05-2023 Can anyone assist in converting this SQL query into ActiveRecord codeigniter? SELECT t.idkas, t.tglkas, ( SELECT (SUM(kredit))-(SUM(debet)) FROM kaskecil t2 WHERE t2.idkas <= t.idkas ) AS total FROM kaskecil t RE: Need help converting SQL to ActiveRecord? - brabus - 07-13-2023 I dont is it works: Hey ChatGPT, convert this sql query to codeigniter 3 active record: Code: SELECT t.idkas, t.tglkas, ( ChatGPT You can convert the SQL query to CodeIgniter 3 Active Record format using the following code: PHP Code: $this->db->select('t.idkas, t.tglkas'); This code will perform the same query as your SQL query using CodeIgniter 3 Active Record. The subquery is created using the get_compiled_select() method to generate the subquery string. The resulting subquery is then used as a select expression in the main query. Finally, the get() method is called to execute the query and retrieve the results. Just start to chat with ChatGPT it will be your friend/mentor, even if he we will not help youu 100%, he can try to help find the path... |