Read an ORACLE cursor. How? - 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: Read an ORACLE cursor. How? (/showthread.php?tid=59620) |
Read an ORACLE cursor. How? - El Forum - 10-28-2013 [eluser]duartix[/eluser] I've managed to get all of the transactional (inserts, updates and deletes) bit of my ORACLE application to execute on the database through stored procedure executions on packages, called by CI's models. This is very important because it relegates data access permissions to the roles that grant those packages' execution rights. However, my queries are still running directly on the tables via direct SELECTs through CI's models. Basically I don't know how to read an ORACLE cursor into a CodeIgniter's model, but I'm willing to push all those SELECT's to the DB because it will make the application more consistent, easier to manage and easier to maintain (the rest of the team is a lot more proficient on PL/SQL than PHP) Does anyone have a light on how to do this? The DB part would be along these lines: Code: CREATE OR REPLACE PACKAGE test_pack IS Thank you in advance. Read an ORACLE cursor. How? - El Forum - 10-31-2013 [eluser]duartix[/eluser] If no one knows a way to do it, do you know of any framework/lib/package that automates this? Read an ORACLE cursor. How? - El Forum - 11-07-2013 [eluser]duartix[/eluser] Well, yesterday I managed to build a proof of concept, and I'm very happy to say that with very little OO programming, I managed to solve the problem and I spent the rest of the day moving all my SELECTS from the models to Stored Procedures in the DB that return cursors. Since this can help someone else, I'm publishing it here in condensed form. Here's what I had to do. First thing I needed, was to create a subclass that extends CI's CI_Model (the code is stripped of exception handling for size and clarity) : Code: <?php Then your models will now look like this: Code: <?php Finally, your ORACLE DB will have a package with a function that returns a cursor with the data (I'll put just the body): Code: CREATE OR REPLACE PACKAGE BODY myschema.mypackage |