Welcome Guest, Not a member yet? Register   Sign In
bringing two controller functions into one controller function
#1

[eluser]Brad K Morse[/eluser]
I am new to CI, I have a function for exporting/writing a csv, then another to send an email w/ that csv file.

Is it possible to create a controller function that brings those two together?

Code:
function export($id) {
// export into csv
}

function email($id) {
// send csv
}

function sendExport($id) {
export($id);
email($id);
}

I know this can't be done, but any direction as how it should be done is appreciated.
#2

[eluser]Greg Aker[/eluser]
Read up on protected/private class methods at PHP.net.

CodeIgniter will protect a controller method prefixed with '_' from public view. So your code can be like:


Code:
function _export($id)
{
    // do export stuff here
}

function _email($id)
{
    // do email stuff here
}

function send_export()
{
    $id = $this->uri->segment(3);
    $this->_export($id);
    $this->_email($id);
}

I hope that helps

-greg
#3

[eluser]Brad K Morse[/eluser]
Thanks Greg! That did the trick.




Theme © iAndrew 2016 - Forum software by © MyBB