首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >代码点火器控制器在胖牛服务器上显示500

代码点火器控制器在胖牛服务器上显示500
EN

Stack Overflow用户
提问于 2014-09-18 07:36:46
回答 1查看 300关注 0票数 0

你好,我有一个使用codeigniter的php代码。它在本地主机上运行得很好。当我把它上传到肥牛服务器后,它就失败了。但不完全只有一个控制器。有四个控制器(页面,帖子,培训,用户),每个控制器工作良好,除了帖子。当我尝试加载posts控制器的函数时,它显示了500条错误消息。

我尝试将posts控制器重命名为reports,它的模型report也重命名为视图,但它并没有解决我的问题

代码语言:javascript
复制
current file names: 
model: report.php
controller: reports.php
view: report/index.php, report/view.php

*编辑这里是reports.php *

代码语言:javascript
复制
class Reports extends MY_Controller {
  public function __construct() {
    parent::__construct();
  }

  public function index() {
    //Pagination Configuration
    $this->custom_config["total_rows"] = $this->report->record_count($tag);
    $this->custom_config["per_page"] = 5;
    $choice = $this->custom_config["total_rows"] / $this->custom_config["per_page"];
    $this->custom_config["num_links"] = round($choice);
    $this->pagination->initialize($this->custom_config);
    $page = ($this->uri->segment($this->custom_config["uri_segment"])) ? $this->uri->segment($this->custom_config["uri_segment"]) : 0;

    $data['tags'] = explode(',', $this->report->tags()['tags']);
    $data['tags'] = array_unique($data['tags']);
    $data['reports'] = $this->report->get($this->custom_config["per_page"], $page);
    $this->load->view('template/head');
    $this->load->view('template/header');
    $this->load->view('reports/index', $data);
    $this->load->view('template/footer', $this->footer);
  }

  public function tag($tag = FALSE) {
    $tag = ($tag !== FALSE) ? urldecode($tag) : $tag;

    //Pagination Configuration
    $this->custom_config["total_rows"] = $this->report->record_count($tag);
    $this->custom_config["per_page"] = 5;
    $choice = $this->custom_config["total_rows"] / $this->custom_config["per_page"];
    $this->custom_config["num_links"] = round($choice);
    $this->pagination->initialize($this->custom_config);
    $page = ($this->uri->segment($this->custom_config["uri_segment"])) ? $this->uri->segment($this->custom_config["uri_segment"]) : 0;

    $data['tags'] = explode(',', $this->report->tags()['tags']);
    $data['tags'] = array_unique($data['tags']);
    $data['reports'] = $this->report->get($this->custom_config["per_page"], $page, FALSE, $tag);
    $this->load->view('template/head');
    $this->load->view('template/header');
    $this->load->view('reports/index', $data);
    $this->load->view('template/footer', $this->footer);

  }

  public function view($slug) {
    $data['tags'] = explode(',', $this->report->tags()['tags']);
    $data['tags'] = array_unique($data['tags']);
    $data['report'] = $this->report->get(1, 0, $slug);
    if(empty($data['report'])) {
      show_404();
    } else {
      $this->load->view('template/head');
      $this->load->view('template/header');
      $this->load->view('reports/view', $data);
      $this->load->view('template/footer', $this->footer);
    }
  }
}

*编辑这里是report.php (模型)*

代码语言:javascript
复制
class Report extends CI_Model {
  function __construct() {
    parent::__construct();
  }

  function record_count($tag = FALSE) {
    $this->db->from('categories');
    $this->db->join('contents','categories.id = contents.category_id');
    $this->db->where('categories.name', 'post');
    if ($tag !== FALSE) {
      $this->db->like('status', $tag);
    }
    return $this->db->count_all_results();
  }

  function get($limit, $start, $slug = FALSE, $tag = FALSE) {
    if($this->session->userdata('language') == 'english') {
      $this->db->select('slug, status, name_en as name, content_en as content, started_on, ended_on, admins.name as author');
    } else {
      $this->db->select('slug, status, contents.name, content, started_on, ended_on, admins.name as author');
    }
    $this->db->limit($limit, $start);
    $this->db->from('categories');
    $this->db->join('contents','categories.id = contents.category_id');
    $this->db->join('admins','admins.id = contents.admin_id');
    $this->db->where('categories.name', 'post');
    $this->db->order_by("contents.id", "desc");
    if ($tag !== FALSE) {
      $this->db->like('status', $tag);
    }
    if ($slug !== FALSE) {
      $this->db->where('slug', $slug);
      $query = $this->db->get();
      return $query->row_array();
    }
    $query = $this->db->get();
    return $query->result_array();
  }

  function get_footer() {
    if($this->session->userdata('language') == 'english') {
      $this->db->select('slug, name_en as name');
    }
    $this->db->from('categories');
    $this->db->join('contents','categories.id = contents.category_id');
    $this->db->where('categories.name', 'post');
    $this->db->order_by("contents.id", "desc");
    $this->db->limit(2);
    $query = $this->db->get();
    return $query->result_array();
  }

  function tags() {
    $this->db->select('group_concat(status) as tags');
    $this->db->from('categories');
    $this->db->join('contents','categories.id = contents.category_id');
    $this->db->where('categories.name', 'post');
    $query = $this->db->get();
    return $query->row_array();
  }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-18 09:37:37

好的,首先,这是我的错,感谢Michael O'Brien。并发布了解决方案。希望有一天能帮上忙。

问题在于mysql版本。我在script上使用了concat_group,它的工作能力仅大于MySQL5.6。版本为5.5。我用下面的内容代替了group_concat,它起作用了。

代码语言:javascript
复制
function tags() {
    $this->db->select('status as tag');
    $this->db->from('categories');
    $this->db->join('contents','categories.id = contents.category_id');
    $this->db->where('categories.name', 'post');
    $query = $this->db->get();
    return $query->result_array();
}


$temp = '';
$data['tags'] = $this->mpost->tags();
foreach ($data['tags'] as $row) {
    $temp .= $row['tag'].",";
}
$data['tags'] = explode(',', $temp);
$data['tags'] = array_unique($data['tags']);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25906847

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档