2016-06-01 13 views
0

私はCodeigniterを新しくしています、私を助けてください。Codeigniterのカテゴリからすべてのデータを取得するには

マイCodeIgniterのURLがある - http://localhost/framework/CodeIgniter/index.php/restaurant/patna/

私はすべてのデータを取得したいです。

は私がルートを設定 -

$route['restaurant(:any)'] = "Restaurant/getRestaurantByCity/$1"; 

とコントローラの私の機能は、ここで

私はそのカテゴリのすべてのデータを取得するために、以下の機能でCAT_IDを渡すカテゴリIDをしたいです

public function getRestaurantByCity() 
{ 
    $rst_list = $this->Restaurant_model->get_restaurant_by_city(); 
} 

答えて

0

この

詐欺をしてみてくださいトローラ

$this->data['RestaurantByCity'] = $this->Restaurant_model->getRestaurantByCity(); 
    echo "<pre>"; print_R($this->data['RestaurantByCity']); 

モデル

public function getRestaurantByCity($ids){ 
    $sql ="select * from categoriestableName where categories_id in($ids) order by categories_id asc"; 
    $rs = $this->db->query($sql); 
    foreach($rs->result() as $record){ 
     $result[] = $record; 
    } 
    return $result; 
} 
0

これは動作するはず

<?php 

if (!defined('BASEPATH')) exit('No direct script access allowed'); 

class Restaurant extends CI_Controller 
{ 
    public function __construct() 
    { 
     parent::__construct(); 
    } 

    public function getRestaurantByCity($id) 
    { 
     $this->load->model('Restaurant_model'); 
     $rst_list = $this->Restaurant_model->get_restaurant_by_city($id); 
    } 
} 
関連する問題