CodeIgniter Forums
Returning transaction status and record data simultaneously - 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: Returning transaction status and record data simultaneously (/showthread.php?tid=42510)



Returning transaction status and record data simultaneously - El Forum - 06-09-2011

[eluser]Wayne Smallman[/eluser]
Hi guys!

I'm at a planned stage in a project where I want to implement transactions. However, having read through a thread I'd been looking at, which provided a novel way of managing transactions, I have a question which hasn't been answered by the author of the code, so I'm posting here, in the hope that someone will have an answer.

In the example the author provides for inserting something, the method needs to return the status of the transaction itself:
Code:
function insertSomething()
    {
        $this->trans_start();
        //perform query
        $this->trans_complete();
        
        return $this->db->trans_status() !== FALSE;
    }
However, with the methods I have for inserting records, I need to return their IDs, too. So what's the best way of accomplishing this, other than rolling the two types of data into an array, or is their a better technique?