Welcome Guest, Not a member yet? Register   Sign In
Issue with session in Datamapper 1.80
#1

[eluser]da_mage[/eluser]
Hi there,
I have been using codeigniter for about a year now and used snippets like this one all over the place
-------------------------------------------------------------------------------------------
Code:
if(!$town->save())
    {
       log_message ( 'ERROR' , 'Could not create town' );
       $this->session->set_flashdata ('error','<p> cannot create town</p>');
       redirect ( 'frontend/page_create_town' );
    }
-------------------------------------------------------------------------------------------

I recently decided to start using Datamapper ORM v 1.80 as my ORM of choice.
But when I paste the exact same snippet in any of my Datamapper extended models I get this error:

Fatal error: Call to a member function set_flashdata() on a non-object

What on earth am I doing wrong...I have been looking on the forums and did't find a similar issue,
#2

[eluser]WanWizard[/eluser]
CI objects aren't assigned to Datamapper models, because you don't load them using $this->load->model().

If you want to use them, do the same as you do in a library:
Code:
if(!$town->save())
    {
       log_message ( 'ERROR' , 'Could not create town' );
       $CI =& get_instance();
       $CI->session->set_flashdata ('error','<p> cannot create town</p>');
       redirect ( 'frontend/page_create_town' );
    }
#3

[eluser]da_mage[/eluser]
Thank you WanWizard , like always you're awesome.




Theme © iAndrew 2016 - Forum software by © MyBB