Welcome Guest, Not a member yet? Register   Sign In
Get image url from model good practice?
#10

(This post was last modified: 11-11-2015, 01:06 AM by sebastianvirlan.)

(11-10-2015, 02:07 PM)dubefx Wrote: @sintakonte very interesting aproach, i learned something new today, so thanks. But CI3 already have this functionality custom_result_object and custom_row_object and can be used in your example model like:
Code:
public function entries_by_limit($start, $limit, $order_by = "order by id_produs asc", $rez)
{
   $this->db->select('a.*');
   $this->db->select('b.nume_imagine', false);
   $this->db->from("$this->_table a");
   $this->db->join('imagini_produse b', "b.$this->_primary_key = a.id_produs", "left");
   $this->db->limit($limit, $start);
   $this->db->order_by($order_by);
   $query = $this->db->get_compiled_select()
   $result = $this->db->query($query);
   return $result->custom_result_object('Produse_Object');
}
Autoload for _Object is still required, but if you don't want to register new autoload simply add at the end of Produse model the Produse_Object class and is done. Also you can access all CI mega object by adding:
Code:
   public function __get($name)
   {
      return get_instance()->$name;
   }
in Produse_Object class (in case you are not extending Produse class).[/code]

So is still need for hook? Please post your full final code. I don't see where you pass $rez.
Reply


Messages In This Thread



Theme © iAndrew 2016 - Forum software by © MyBB