【发布时间】:2015-06-07 10:04:42
【问题描述】:
我尝试使用 - 连字符创建一些控制器、模型和视图,但我总是收到 php 错误,所以我现在使用下划线。
所以我的网址是: http://localhost:8888/ci/index.php/get_artist_discography/artist_name
我希望是这样的: http://localhost:8888/ci/index.php/get-artist-discography/artist-name
codeigniter 中可能有带有 - 连字符的 url?
我的代码:
/控制器:
<?php
include (APPPATH.'/libraries/REST_Controller.php');
class get_artist_discography extends REST_Controller {
function artist_name_get(){
$data = new stdClass();
$this->load->model('artist_model');
$data = $this->artist_model->getAll();$this->response($data, 200);
}
}
/模型:
<?php
class artist_model extends CI_Model {
function getAll(){
$q = $this->db->query("SELECT artist_discography,artist_name from music");
if($q->num_rows() > 0) {
foreach ($q->result() as $row) {
$data [] = $row;
}
return $data;
}
}
}
【问题讨论】:
标签: php codeigniter url