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

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

Is this method a good practice?

Controller:

PHP Code:
$produse $this->produse->entries_by_limit((($page-1) * $config_pagina['per_page']),
 
$config_pagina['per_page'], $order_by'270'); 

Model:

PHP Code:
   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);
 
       $result $this->db->get();

 
       foreach($result->result() as $single) {

 
        if($single->nume_imagine):
 
        $single->nume_imagine base_url('assets/uploads/'.$single->id_produs.'/'.$this->parse_image($single->nume_imagine$rez));
 
           else:
 
               $single->nume_imagine base_url('assets/images/no-product-image-available.png');
 
           endif;
 
       }

 
       return $result->result();
 
   }


 
   function parse_image($image_name$rez){
 
       $image explode('.'$image_name);
 
       return $image[0].'_'.$rez.'.'.$image[1];

 
   


and view

PHP Code:
<img class="primary-image" src="<?= $produs->nume_imagine ?>" alt=""


Should I use any helper or is ok like this?
Reply


Messages In This Thread
Get image url from model good practice? - by sebastianvirlan - 11-06-2015, 07:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB