2

I have this select

    $this->db->select('modulo_regra.regra_descricao');
    $this->db->from('modulo_regra');
    $this->db->where('modulo_regra.modulo_regra_id', id);
    $query = $this->db->get();

that return to me 2 elements in

  return $query->result_array();

Then I put the return in a Array

   $permissoes =array('areas' => $this->Regra_model->user_has($regra['regra_id']));

then I the $permissoes to the session

   $this->session->set_userdata($permissoes);

So the real problem comes here. when I'm loading the value from session

   $permissoes = array('areas');
   $permissoes = $this->session->userdata('areas'); 

this is its content:

array(2) ([0] => array(1) ([regra_descricao] => (string) clientes_cadastrar)
          [1] => array(1) ([regra_descricao] => (string) clientes_visualizar))

So i can't validate it with the in_array(), or other way...I would like to know if there is how if there is away to compare the value in this array with one another variable

like

if(in_array('clientes_cadastrar',$permissoes)){}

I'm new on it... so sorry for the way i ask.

1
  • 3
    Instead of $permissoes = array('areas'); try doing $permissoes = array['areas']; Commented Feb 24, 2012 at 22:22

2 Answers 2

3

don't put entire array in return i.e

foreach ($query->result() as $row)
{
   $return[] = $row->regra_descricao;
}
return $return;

THEN

you can easily find using:

if(in_array('clientes_cadastrar',$permissoes[**'areas'**])){}

hope this helps

Sign up to request clarification or add additional context in comments.

Comments

1

U can use the same scope.

 $this->db->select('modulo_regra.regra_descricao');
     $this->db->from('modulo_regra');
     $this->db->where('modulo_regra.modulo_regra_id', id);
     $query = $this->db->get();

    foreach ($query->result() as $row)
    {
       $permissoes = array['areas'];
    }

    $this->session->set_userdata($permissoes);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.