Boris Kuzevanov
Boris Kuzevanov

Reputation: 1302

Codeigniter, Postgresql and keys insensitivity

I have one proble. I have my site based on Codeigniter framework, with postgresql database. If i do this code:

$this->db->select('id');
$this->db->where(array('name' => 'moscow'));
$this->db->get('Cities');

I have empty result.

but in my table i have city with field name = Moscow.

How i can to resolve this problem?

Thanks.

Upvotes: 0

Views: 89

Answers (2)

Lokesh Jain
Lokesh Jain

Reputation: 579

try this code

  $this->db->select('id,name');
  $this->db->from('Cities');
  $this->db->where('name','moscow');

  $sql= $this->db->get();
  if($sql->num_rows()>0)
  {
      return $sql->result();
  }   
  else{

      return FALSE;
  }

Upvotes: 0

Jenz
Jenz

Reputation: 8369

Your query is wrong. Remove the from condition. $this->db->get('Cities'); produces:

 SELECT * FROM cities 

so no need of an extra from condition. Change your query to :

$this->db->select('id');
$this->db->where(array('name' => 'moscow'));
$this->db->get('Cities');

Upvotes: 1

Related Questions