0

我正在尝试将 index.php 文件中的变量传递给 action_index,以便在查询之间进行更改。

<?php defined('SYSPATH') or die('No direct script access.');                                                                                                                                               

class Controller_Rest_Chart extends Controller {                                                                                                                                                           

    public function action_index()                                                                                                                                                                         
    {                                                                                                                                                                                                                                                                                                        

    if ($test < 2)                                                                                                                                                                                                        
        $result = DB::query(Database::SELECT, "SELECT date AS label,sales_order AS value FROM chart_sales where date >= '{$_GET['start']}'::DATE AND date <= '{$_GET['end']}'::DATE order by date desc")   
            ->execute()                                                                                                                                                                                    
            ->as_array();                                                                                                                                                                                  
         else    
            $result = DB::query(Database::SELECT, "SELECT date AS label,sales_order AS value FROM chart_sales where date >= '{$_GET['start']}'::DATE AND date <= '{$_GET['end']}'::DATE order by date asc")   
            ->execute()                                                                                                                                                                                    
            ->as_array(); 

            echo (json_encode($result));     

    }                                                                                                                                                                                                      

}    
4

1 回答 1

0

是的,您可以。我建议您在此处阅读有关路由的信息:http: //kohanaframework.org/3.3/guide/kohana/routing
如果您使用的是默认路由,那么如果您可以像这样发送您想要的变量

<ur website>/Rest_Chart/index/2

并像这样获取它

$test = $this->request->param('id');

PS:[题外话]不确定你的控制器名称的coice ...使用'_'表示kohana中的一个子目录,你应该使用camelcases。

于 2013-09-17T13:57:30.080 回答