Codeigniter Model appending word_limiter to result object

Posted by yahyaE on Stack Overflow See other posts from Stack Overflow or by yahyaE
Published on 2011-11-21T09:46:47Z Indexed on 2011/11/21 9:50 UTC
Read the original article Hit count: 199

Filed under:
|
|
|
|

I have a get_all function in my model class in Codeigniter 2.0+. For a given database field name, i need to use word_limiter() in text helper. In view page, i loop result set as object $row->field_name_to_be_limited. With below code, i am trying to do it. But i should include the change $q->$field_name = word_limiter($q->$field_name, 4); into the $q->result. Thanks for help.

function get_all($table_name,$orderByField,$ascDesc,$field_name = '')
{
  $this->load->helper('text');
  $qOrder = $this->db->order_by($orderByField,$ascDesc);
  $q = $this->db->get($table_name,$qOrder);
  if( ! $field_name ==='') $q->$field_name = word_limiter($q->$field_name, 4);
  return $q->result();
}

© Stack Overflow or respective owner

Related posts about php

Related posts about mvc