У меня есть раздел моего кода, из-за которого вся моя страница загружается белым без сообщения об ошибке.
Я отладил свой код, и следующий раздел вызывает мою проблему, но я не могу понять, почему:
Код проблемы:
if($this->image_model->updatePage($id, $caption)) {
$data['title'] = 'Image Captions';
$data['cms_pages'] = $this->navigation_model->getCMSPages();
$data['sales_pages'] = $this->sales_model->getSalesPages();
$data['get_images'] = $this->image_model->getImages();
$data['content'] = $this->load->view('admin/imagecaption', $data, TRUE); #Loads the "content"
$this->load->view('admintemplate', $data); #Loads the given template and passes the $data['content'] into it
}//END if updatePage
Полный документ управления:
function index(){
if(!$this->session->userdata('logged_in'))redirect('admin/home');
$data['title'] = 'Image Captions';
$data['cms_pages'] = $this->navigation_model->getCMSPages();
$data['sales_pages'] = $this->sales_model->getSalesPages();
$data['get_images'] = $this->image_model->getImages();
$data['content'] = $this->load->view('admin/imagecaption', $data, TRUE); #Loads the "content"
$this->load->view('admintemplate', $data); #Loads the given template and passes the $data['content'] into it
if ($this->input->post('submit')){
#The User has submitted updates, lets begin!
#Set The validation Rules
$this->form_validation->set_rules('captionInput', 'Caption', 'trim|required|xss_clean');
if ($this->form_validation->run() == FALSE){ #Form Validation Fails Load The Default Page
$data['title'] = 'Image Captions';
$data['cms_pages'] = $this->navigation_model->getCMSPages();
$data['sales_pages'] = $this->sales_model->getSalesPages();
$data['get_images'] = $this->image_model->getImages();
$data['content'] = $this->load->view('admin/imagecaption', $data, TRUE); #Loads the "content"
$this->load->view('admintemplate', $data); #Loads the given template and passes the $data['content'] into it
}// END Form Validation
#Form Validation passed, so lets continue updating.
#lets set some variables to pass into the database for editing.
$caption = $this->input->post('captionInput', TRUE);
$this->db->escape($caption); # Lets check for security and mel objects :)
#Now if imageCaption fails to update the database then show "there was a problem".
if($this->image_model->updatePage($id, $caption)) {
$data['title'] = 'Image Captions';
$data['cms_pages'] = $this->navigation_model->getCMSPages();
$data['sales_pages'] = $this->sales_model->getSalesPages();
$data['get_images'] = $this->image_model->getImages();
$data['content'] = $this->load->view('admin/imagecaption', $data, TRUE); #Loads the "content"
$this->load->view('admintemplate', $data); #Loads the given template and passes the $data['content'] into it
}//END if updatePage
}else{
$data['title'] = 'Image Captions';
$data['cms_pages'] = $this->navigation_model->getCMSPages();
$data['sales_pages'] = $this->sales_model->getSalesPages();
$data['get_images'] = $this->image_model->getImages();
$data['content'] = $this->load->view('admin/imagecaption', $data, TRUE); #Loads the "content"
$this->load->view('admintemplate', $data); #Loads the given template and passes the $data['content'] into it
} //END Submit
} //END function index()
}
Модель изображения:
class Image_model extends CI_Model
{
function __construct() {
parent::__construct();
}
function getImages($path = NULL) {
foreach($this->db->get('images')->result_array() as $r) {
$rows[] = $r;
}
return $rows;
}
function addImage($imgdata) {
$this->db->insert('images',$imgdata);
return;
}
function deleteimage($id){
$this->db->where('id', $id);
$q = $this->db->get('images');
$row = $q->row_array();
if ($q->num_rows() > 0){
//delete from the database
$this->db->where('id', $id);
$this->db->delete('images');
//lets delete the image
unlink("includes/uploads/gallery/".$row['imagename']);
//lets delete the thumb.
unlink("includes/uploads/gallery/thumbs/".$row['thumbname']);
}//END if num_rows
}//END function deleteImage($id)
function updateCaption($id = NULL, $caption = NULL){
#set the $data passed to the function into an array, content being the column name.
$data = array('description' => $caption);
$this ->db->where('id',$id);
$this->db->update('images', $data);
return TRUE;
}
}//END class Image_model