CodeIgniter - Syntax error with select and where

0

In a precise project that shows only the active publications on the main page I am using Codeigniter, I have used the following lines of code:

Model:

$this->db->select('*');
$this->db->from("publicacoes");
$this->db->where('ativacao' == '1');
$data = $this->db->get()->result_array();

return $data;

But when I leave this line "uncommented" the application "breaks"

$this->db->where('ativacao' == '1'); 
    
asked by anonymous 26.11.2018 / 11:01

2 answers

2

Change% from% to% with%

    
26.11.2018 / 11:06
1

According to the documentation on the Codeigniter website, the "ideal" way to do this would be:

$this->db->where('ativacao' , '1');

and when you use a where <> there is

$this->db->where('ativacao <>' , '1');
    
29.11.2018 / 18:01