[eluser]CroNiX[/eluser]
It looks like you are only retrieving a single result, so you might want to use
Code:
return $query->row(); //returns single row meeting condition
instead of:
Code:
return $query->result(); //returns an array of all rows meeting condition
Then you wouldn't have to do
foreach ($query as $row){}
in order to get the result.
Code:
public function get_folder_name_by_id($id_folder){
$query = $this->db
->select('folder_name');
->where('id_folder', $id_folder);
->get('create_folder')
->row(); //get a single row
//return the actual name, or FALSE if not found
return (isset($query->folder_name)) ? $query->folder_name : FALSE;
}
Then in your controller you can get rid of that loop that's doing nothing,
Code:
$folder_name = $this->model_media->get_folder_name_by_id($id);
if ($folder_name === FALSE)
{
//handle error, that folder doesn't exist
}
$config['upload_path'] = './uploads/' . $folder_name;