本文整理匯總了PHP中Illuminate\Support\Facades\DB::Table方法的典型用法代碼示例。如果您正苦於以下問題:PHP DB::Table方法的具體用法?PHP DB::Table怎麽用?PHP DB::Table使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\DB
的用法示例。
在下文中一共展示了DB::Table方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: GetHistory
public function GetHistory()
{
if (Auth::check()) {
/*
* Pie chart
*/
$p = new \chartphp();
$DB = DB::Table('users')->select('Apple', 'Car', 'House', 'Gas')->where('id', '=', '2')->get();
$fields = [];
foreach ($DB as $ind => $val) {
foreach ($val as $x => $y) {
$fields[] = [$x, $y];
}
}
$data = [$fields];
$p->data = $data;
$p->chart_type = "pie";
$p->title = "";
$out = $p->render('c2');
/*
* end pie chart
*/
/*
* Line Chart
*/
$p = new \chartphp();
$p->data = array(array(array(48.25, "2014-01-11"), array(95.5, "2014-01-12"), array(238.75, "2014-01-13"), array(286.8, "2014-01-14"), array(300.5, "2014-01-15")));
$p->chart_type = "line";
// Common Options
$p->title = "Sales - 2014 vs 2015";
$p->ylabel = "Sales";
// For Custom Legend Names
$p->series_label = array("2014", "2015");
$p->legend_show = false;
// Date interval for y axis
$p->y_data_type = 'date';
$p->y_tick_interval = '2 day';
$Line = $p->render('c1');
/*
end line chart
*/
$id = Auth::user()->id;
$Acc = $History = DB::table('users')->select('BankAcc', 'StockAcc')->where('id', '=', $id)->get();
$Error = ' ';
$History = DB::table('History')->select('Name', 'StockName', 'price', 'Date')->where('UID', '=', $id)->Take(5)->get();
if ($History == null) {
$Error = 'You Have no purchased Stocks';
return view('pages.Home')->with('Error', $Error)->with('History', $History)->with('Acc', $Acc)->with('out', $out);
} else {
return view('pages.home')->with('History', $History)->with('Error', $Error)->with('Acc', $Acc)->with('out', $out)->with('Line', $Line)->with('data', $data);
}
} else {
return redirect()->intended('auth/login');
}
}