So I have a website where I buy items. I do an if to see if the session data "moedas" (user's coins) is greater than or equal to the item's price. I want to get the item's data from my model where I have the model's function dados_acessorio
. So I call this function on my controller and what I want is to receive that data and be able to use it on the same controller after. The problem is I am getting an error. I am new to php/CodeIgniter and I could use some help.
Here is the controller's function:
public function confirmarCompra($id){
$this->load->model('acessorios_model','acessorios');
$dados['acessorio'] = $this->acessorios->dados_acessorio($id)[0];
if($this->session->moedas >= $acessorio['preco']){
}
}
Here is the model's function:
public function dados_acessorio($id){
return $this->db->from('acessorios')->where('id_acessorio', $id)->get()->result_array();
}
Here is an image of my acessorios
table:
The error that I receive on the controller:
The error is on the following line:
if($this->session->moedas >= $acessorio['preco'])
Thanks!