Welcome Guest, Not a member yet? Register   Sign In
Connection to DB from library
#2

[eluser]mikeyhell[/eluser]
Why not just use the inflector helpers and in your models create a function similar to this:

controller
Code:
$this->model_name->getCat(humanize($this->uri->segment(3)));

Model
Code:
function getCat($catName){
  $this->db->select('id');
  $this->db->where('name', $catName);
  $query= $this->db->get('categories')
  
  if( $query->num_rows() > 0 ):
    $result= $query->result();
  else:
    $result= false;
  endif;

  return $result
}


Messages In This Thread
Connection to DB from library - by El Forum - 03-03-2008, 05:21 PM
Connection to DB from library - by El Forum - 03-03-2008, 07:59 PM
Connection to DB from library - by El Forum - 03-10-2008, 06:03 PM
Connection to DB from library - by El Forum - 03-10-2008, 06:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB