クエリ間で変更するために、変数を 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));
}
}