CodeIgniter Forums
ActiveRecord and Sessions issues? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: ActiveRecord and Sessions issues? (/thread-6446.html)



ActiveRecord and Sessions issues? - El Forum - 02-27-2008

[eluser]bhogg[/eluser]
Hi all,

Got a couple annoying problems and hoping someone might know the answers!

1) Using an ActiveRecord in certain situations will either return all the records, or return nothing at all. I can literally hit Refresh a few times and watch as sometimes the query returns the correct results and others it does not.

$query = $this->db->get($tablename);
$ret = $query->result_array();
return $ret;

There are no errors displayed with debug on when the results are not displayed. Any ideas?

2) I'm using session variables to save the page to re-direct to after another form is submitted. I'm using basic code such as:

$this->session->set_userdata('redirect', 'opportunities/edit/1');

Right after this is set, I can echo $this->session->userdata('redirect') and get the expected result. When I attempt to retrieve the value on the next page, (ie. echo $this->session->userdata('redirect')) it returns 'opportunities/edit/' (the 1 is dropped). Even if I put a / on the end - ie. opportunities/edit/1/, it returns opportunities/edit//.

Why is the digit one being dropped?


Thanks for any and all help you can provide.

Regards,
Brian


ActiveRecord and Sessions issues? - El Forum - 02-29-2008

[eluser]Noah David[/eluser]
1. Try something like this...

Code:
$this->db->select('a, b')->from('d')->where('x', $x);
$query = $this->db->get();
foreach ($query->result() as $row)
{
    echo $row->a;
}
What do you get?

2. No idea. What happens when you replace the 1 with something else, like 'one'? opp/edit/one