Welcome Guest, Not a member yet? Register   Sign In
Concatenate database columns
#1

[eluser]Gerep[/eluser]
Hi fellas....

I have a database with address and address_number columns.

On my search form, the client will type the address and number on the same field so I had to concatenate it and make a LIKE.

I found a way but I'm not sure it's the best.

Code:
$like['concat(address,"",address_number)'] = $house_address;
$this->HouseModel->select($like);

The concat() if a MySQL function.

On my Model class I have:

Code:
public function select($like = NULL) {
if(!is_null($like)) {
   $this->db->like($like);
}

return $this->db->get('houses');
}

If there is a better solution, please tell me =)

If not, I hope it helps someone Wink




Theme © iAndrew 2016 - Forum software by © MyBB