- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前对此感到非常沮丧,我非常感谢任何帮助!
我有一个 SQL 表,用于跟踪人们何时单击网站上的某些按钮。每当有人单击该按钮时,它就会在桌面上创建一个事件。
我目前正在做的是构建一个页面,在 Google 可视化图表上显示这些统计信息。我已经让它工作了,但我 100% 确定有一种更快、更干净的方法来做到这一点。
添加更多详细信息
我想做的是将数据库列类型分组,然后我想计算每组的数量并将其显示在图 TableView 上。这目前正在工作,但我想学习如何缩短 Controller 中的功能。
我是 SQL 新手,最近才学习基础知识,因此希望获得更多指导。
这是数据库的示例:
这是 Controller 中的函数
public function UsedCarsSearch() {
// Used Car Search
$searchmodeldropdown = UsedCarsAnalytics::where('type', '=', 'search-model-dropdown')->count();
$searchmanufacturerdropdown = UsedCarsAnalytics::where('type', '=', 'search-manufacturer-dropdown')->count();
$searchvehiclesbutton = UsedCarsAnalytics::where('type', '=', 'search-vehicles-button')->count();
$searchfueltypedropdown = UsedCarsAnalytics::where('type', '=', 'search-fuel-type-dropdown')->count();
$searchtransmissiondropdown = UsedCarsAnalytics::where('type', '=', 'search-transmission-dropdown')->count();
$searchenginesizedropdown = UsedCarsAnalytics::where('type', '=', 'search-engine-size-dropdown')->count();
$searchdoorsdropdown = UsedCarsAnalytics::where('type', '=', 'search-doors-dropdown')->count();
$refinesearchmobilebutton = UsedCarsAnalytics::where('type', '=', 'refine-search-mobile-button')->count();
$searchseatsdropdown = UsedCarsAnalytics::where('type', '=', 'search-seats-dropdown')->count();
$searchmaxpricedropdown = UsedCarsAnalytics::where('type', '=', 'search-max-price-dropdown')->count();
$menulinkmobilemenusearchbutton = UsedCarsAnalytics::where('type', '=', 'menu-link-mobile-menu-search-button')->count();
$searchmaxmileagedropdown = UsedCarsAnalytics::where('type', '=', 'search-searchbox-dropdown')->count();
$searchsearchboxdropdown = UsedCarsAnalytics::where('type', '=', 'search-max-mileage-dropdown')->count();
$searchminpricedropdown = UsedCarsAnalytics::where('type', '=', 'search-min-price-dropdown')->count();
$searchpostcodedropdown = UsedCarsAnalytics::where('type', '=', 'search-postcode-dropdown')->count();
$search = UsedCarsAnalytics::where('type', '=', 'search')->count();
$searchminmileagedropdown = UsedCarsAnalytics::where('type', '=', 'search-min-mileage-dropdown')->count();
$searchvehiclesbuttonmobiletop = UsedCarsAnalytics::where('type', '=', 'search-vehicles-button-mobile-top')->count();
$approvedusedsearchtab = UsedCarsAnalytics::where('type', '=', 'approved-used-search-tab')->count();
$resetsearchbutton = UsedCarsAnalytics::where('type', '=', 'reset-search-button')->count();
$newsearchtab = UsedCarsAnalytics::where('type', '=', 'new-search-tab')->count();
$servicesearchtab = UsedCarsAnalytics::where('type', '=', 'service-search-tab')->count();
$searchminadvancedpaymentdropdown = UsedCarsAnalytics::where('type', '=', 'search-min-advanced-payment-dropdown')->count();
$searchmaxadvancedpaymentdropdown = UsedCarsAnalytics::where('type', '=', 'search-max-advanced-payment-dropdown')->count();
$resetsearchbuttonmobiletop = UsedCarsAnalytics::where('type', '=', 'reset-search-button-mobile-top')->count();
$searchmaxmonthlypaymentdropdown = UsedCarsAnalytics::where('type', '=', 'search-max-monthly-payment-dropdown')->count();
$searchminmonthlypaymentdropdown = UsedCarsAnalytics::where('type', '=', 'search-min-monthly-payment-dropdown')->count();
// Vehicle Spec Interest
$accordionopenaccordiondriverconvenience = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-driver-convenience')->count();
$accordionopenaccordioninteriorfeatures = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-interior-features')->count();
$accordionopenaccordionexteriorfeatures = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-exterior-features')->count();
$accordionopenaccordionentertainment = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-entertainment')->count();
$accordionopenaccordionsafety = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-safety')->count();
$accordionopenaccordionsecurity = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-security')->count();
$accordionopenaccordionfuelconsumption = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-fuel-consumption')->count();
$accordionopenaccordionperformance = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-performance')->count();
$accordionopenaccordionwheels = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-wheels')->count();
$accordionopenaccordiongeneral = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-general')->count();
$accordionopenaccordiontechnical = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-technical')->count();
$accordionopenaccordionemissions = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-emissions')->count();
$accordionopenaccordionengineanddrivetrain = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-engine-and-drive-train')->count();
$accordionopenaccordiontyres = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-tyres')->count();
$accordionopenaccordiontrim = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-trim')->count();
$accordionopenaccordionweightandcapacities = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-weight-and-capacities')->count();
$accordionopenaccordionvehicledimensions = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-vehicle-dimensions')->count();
$accordionopenaccordionpacks = UsedCarsAnalytics::where('type', '=', 'accordion-open accordion-packs')->count();
$accordionopeninteriorfeatures = UsedCarsAnalytics::where('type', '=', 'accordion-open interior-features')->count();
// Bodystyle Interest
$hatchback = UsedCarsAnalytics::where('type', '=', 'hatchback-option-checkbox')->count();
$estate = UsedCarsAnalytics::where('type', '=', 'estate-option-checkbox')->count();
$suv = UsedCarsAnalytics::where('type', '=', 'suv-option-checkbox')->count();
$fourxfour = UsedCarsAnalytics::where('type', '=', '4x4-option-checkbox')->count();
$mpv = UsedCarsAnalytics::where('type', '=', 'mpv-option-checkbox')->count();
$saloon = UsedCarsAnalytics::where('type', '=', 'saloon-option-checkbox')->count();
$sport = UsedCarsAnalytics::where('type', '=', 'sport-option-checkbox')->count();
$convertible = UsedCarsAnalytics::where('type', '=', 'convertible-option-checkbox')->count();
$coupes = UsedCarsAnalytics::where('type', '=', 'coupes-option-checkbox')->count();
$pickup = UsedCarsAnalytics::where('type', '=', 'pickup-option-checkbox')->count();
$crewvan = UsedCarsAnalytics::where('type', '=', 'crew-van-option-checkbox')->count();
$doublecab = UsedCarsAnalytics::where('type', '=', 'double-cab-option-checkbox')->count();
$minibus = UsedCarsAnalytics::where('type', '=', 'minibus-option-checkbox')->count();
$tipper = UsedCarsAnalytics::where('type', '=', 'tipper-option-checkbox')->count();
$dropside = UsedCarsAnalytics::where('type', '=', 'dropside-option-checkbox')->count();
$luton = UsedCarsAnalytics::where('type', '=', 'luton-option-checkbox')->count();
$chassis = UsedCarsAnalytics::where('type', '=', 'chassis-option-checkbox')->count();
$box = UsedCarsAnalytics::where('type', '=', 'box-option-checkbox')->count();
$curtainslider = UsedCarsAnalytics::where('type', '=', 'curtainslider-option-checkbox')->count();
$platformcab = UsedCarsAnalytics::where('type', '=', 'platform-cab-option-checkbox')->count();
$refridgerated = UsedCarsAnalytics::where('type', '=', 'refridgerated-option-checkbox')->count();
$freezer = UsedCarsAnalytics::where('type', '=', 'freezer-option-checkbox')->count();
// Options Interest
$airconditioning = UsedCarsAnalytics::where('type', '=', 'air-conditioning-option-checkbox')->count();
$bluetooth = UsedCarsAnalytics::where('type', '=', 'bluetooth-option-checkbox')->count();
$satnav = UsedCarsAnalytics::where('type', '=', 'sat-nav-option-checkbox')->count();
$cruisecontrol = UsedCarsAnalytics::where('type', '=', 'cruise-control-option-checkbox')->count();
$parkingsensors = UsedCarsAnalytics::where('type', '=', 'parking-sensors-option-checkbox')->count();
$heatedwindscreen = UsedCarsAnalytics::where('type', '=', 'heated-windscreen-option-checkbox')->count();
$cdplayer = UsedCarsAnalytics::where('type', '=', 'cd-player-option-checkbox')->count();
$dabradio = UsedCarsAnalytics::where('type', '=', 'dab-radio-option-checkbox')->count();
$auxinput = UsedCarsAnalytics::where('type', '=', 'aux-input-option-checkbox')->count();
$parkassist = UsedCarsAnalytics::where('type', '=', 'park-assist-option-checkbox')->count();
$phonenav = UsedCarsAnalytics::where('type', '=', 'phone-nav-option')->count();
$heatedseats = UsedCarsAnalytics::where('type', '=', 'heated-seats-option-checkbox')->count();
$parkingcamera = UsedCarsAnalytics::where('type', '=', 'parking-camera-option-checkbox')->count();
$leatherinterior = UsedCarsAnalytics::where('type', '=', 'leather-interior-option-checkbox')->count();
$keylessentry = UsedCarsAnalytics::where('type', '=', 'keyless-entry-option-checkbox')->count();
$dvdplayer = UsedCarsAnalytics::where('type', '=', 'dvd-player-option-checkbox')->count();
$metallicpaint = UsedCarsAnalytics::where('type', '=', 'metallic-paint-option-checkbox')->count();
$mp3player = UsedCarsAnalytics::where('type', '=', 'mp3-player-option-checkbox')->count();
$spoiler = UsedCarsAnalytics::where('type', '=', 'spoiler-option-checkbox')->count();
// Image Interests
$interiorinterests = UsedCarsAnalytics::where('type', '=', 'interior-images-tab')->count();
$exteriorinterests = UsedCarsAnalytics::where('type', '=', 'exterior-images-tab')->count();
$featuresinterests = UsedCarsAnalytics::where('type', '=', 'features-images-tab')->count();
$allinterests = UsedCarsAnalytics::where('type', '=', 'all-images-tab')->count();
$imagesonlyinterests = UsedCarsAnalytics::where('type', '=', 'images-only-option-checkbox')->count();
// Sort By Button
$sortByButton = UsedCarsAnalytics::where('type', '=', 'sort-bar-dropdown')->count();
return View::make('reports.used-cars-search', compact(
'searchmodeldropdown',
'searchmanufacturerdropdown',
'searchvehiclesbutton',
'searchfueltypedropdown',
'searchtransmissiondropdown',
'searchenginesizedropdown',
'searchdoorsdropdown',
'refinesearchmobilebutton',
'searchseatsdropdown',
'searchmaxpricedropdown',
'menulinkmobilemenusearchbutton',
'searchmaxmileagedropdown',
'searchsearchboxdropdown',
'searchminpricedropdown',
'searchpostcodedropdown',
'search',
'searchminmileagedropdown',
'searchvehiclesbuttonmobiletop',
'approvedusedsearchtab',
'resetsearchbutton',
'newsearchtab',
'servicesearchtab',
'searchminadvancedpaymentdropdown',
'searchmaxadvancedpaymentdropdown',
'resetsearchbuttonmobiletop',
'searchmaxmonthlypaymentdropdown',
'searchminmonthlypaymentdropdown',
'accordionopenaccordiondriverconvenience',
'accordionopenaccordioninteriorfeatures',
'accordionopenaccordionexteriorfeatures',
'accordionopenaccordionentertainment',
'accordionopenaccordionsafety',
'accordionopenaccordionsecurity',
'accordionopenaccordionfuelconsumption',
'accordionopenaccordionperformance',
'accordionopenaccordionwheels',
'accordionopenaccordiongeneral',
'accordionopenaccordiontechnical',
'accordionopenaccordionemissions',
'accordionopenaccordionengineanddrivetrain',
'accordionopenaccordiontyres',
'accordionopenaccordiontrim',
'accordionopenaccordionweightandcapacities',
'accordionopenaccordionvehicledimensions',
'accordionopenaccordionpacks',
'accordionopeninteriorfeatures',
'hatchback',
'estate',
'suv',
'fourxfour',
'mpv',
'saloon',
'sport',
'convertible',
'coupes',
'pickup',
'crewvan',
'doublecab',
'minibus',
'tipper',
'dropside',
'luton',
'chassis',
'box',
'curtainslider',
'platformcab',
'refridgerated',
'freezer',
'airconditioning',
'bluetooth',
'satnav',
'cruisecontrol',
'parkingsensors',
'heatedwindscreen',
'cdplayer',
'dabradio',
'auxinput',
'parkassist',
'phonenav',
'heatedseats',
'parkingcamera',
'leatherinterior',
'keylessentry',
'dvdplayer',
'metallicpaint',
'mp3player',
'spoiler',
'interiorinterests',
'exteriorinterests',
'featuresinterests',
'allinterests',
'imagesonlyinterests',
'sortByButton'
));
这是 View Blade :
@extends('templates/master')
@section('content')
<style type="text/css">
.analytics-charts {
display: inline-block;
width: 32.2%;
height: 400px;
border: 1px solid #ddd;
vertical-align: top;
border-radius: 10px;
background: #f5f5f5;
padding: 20px;
margin-right: 1.45%;
margin-bottom: 1.45%;
}
.analytics-single {
display: inline-block;
border: 1px solid #ddd;
vertical-align: top;
border-radius: 10px;
background: #f5f5f5;
padding: 20px;
margin-right: 1.45%;
margin-bottom: 1.45%;
}
</style>
<h1>Used Car Search Web Analytics</h1>
<div class="analytics-charts">
<h2>Used Car Search</h2>
<h3>Click Count</h3>
<div id="pieChart"></div>
</div>
<div class="analytics-charts">
<h2>Vehicle Spec Interest</h2>
<h3>Click Count</h3>
<div id="pieChartVehicle"></div>
</div>
<div class="analytics-charts">
<h2>Bodystyle Interests</h2>
<h3>Click Count</h3>
<div id="pieChartBody"></div>
</div>
<div class="analytics-charts">
<h2>Options Interests</h2>
<h3>Click Count</h3>
<div id="pieChartOptIn"></div>
</div>
<div class="analytics-charts">
<h2>Image Interests</h2>
<h3>Click Count</h3>
<div id="pieChartImgInt"></div>
</div>
<div class="analytics-single">
<h2>Sort By</h2>
<h3>Click Count {{ $sortByButton }}</h3>
</div>
@stop
@section('scripts')
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<!-- Used Car Search Pie -->
<script>
google.charts.load('current', {'packages': ['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Used Car Search');
data.addColumn('number', 'Click Count');
data.addRows([
['Model', <?php echo $searchmodeldropdown ?>],
['Manufacturer', <?php echo $searchmanufacturerdropdown ?>],
['Vehicles Button', <?php echo $searchvehiclesbutton ?>],
['Fuel Type', <?php echo $searchfueltypedropdown ?>],
['Transmission', <?php echo $searchtransmissiondropdown ?>],
['Engine Size', <?php echo $searchenginesizedropdown ?>],
['Doors', <?php echo $searchdoorsdropdown ?>],
['Refine Search Mobile', <?php echo $refinesearchmobilebutton ?>],
['Seats', <?php echo $searchseatsdropdown ?>],
['Max Price', <?php echo $searchmaxpricedropdown ?>],
['Menu Link Mobile Menu Search', <?php echo $menulinkmobilemenusearchbutton ?>],
['Max Mileage', <?php echo $searchmaxmileagedropdown ?>],
['Searchbox', <?php echo $searchsearchboxdropdown ?>],
['Min Price', <?php echo $searchminpricedropdown ?>],
['Postcode', <?php echo $searchpostcodedropdown ?>],
['Search', <?php echo $search ?>],
['Min Mileage', <?php echo $searchminmileagedropdown ?>],
['Vehicles Button Mobile Top', <?php echo $searchvehiclesbuttonmobiletop ?>],
['Approved Used Search Tab', <?php echo $approvedusedsearchtab ?>],
['Reset Search Button', <?php echo $resetsearchbutton ?>],
['New Search Tab', <?php echo $newsearchtab ?>],
['Service Search Tab', <?php echo $servicesearchtab ?>],
['Min advanced Payment', <?php echo $searchminadvancedpaymentdropdown ?>],
['Max advanced Payment', <?php echo $searchmaxadvancedpaymentdropdown ?>],
['Reset Search Button Mobile Top', <?php echo $resetsearchbuttonmobiletop ?>],
['Search Max Monthly Payment', <?php echo $searchmaxmonthlypaymentdropdown ?>],
['Search Min Monthly Payment', <?php echo $searchminmonthlypaymentdropdown ?>],
]);
var options = {
title: 'My Daily Activities',
};
options.chartArea = {left: 0, 'width': '90%', 'height': '90%'}
var chart = new google.visualization.PieChart(document.getElementById('pieChart'));
chart.draw(data, options);
}
</script>
<!-- Vehicle Spec Interest Pie -->
<script>
google.charts.load('current', {'packages': ['corechart']});
google.charts.setOnLoadCallback(drawChartVehicle);
function drawChartVehicle() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Used Car Search');
data.addColumn('number', 'Click Count');
data.addRows([
['Driver Convenience', <?php echo $accordionopenaccordiondriverconvenience ?>],
['Interior Features', <?php echo $accordionopenaccordioninteriorfeatures ?>],
['Exterior Features', <?php echo $accordionopenaccordionexteriorfeatures ?>],
['Entertainment', <?php echo $accordionopenaccordionentertainment ?>],
['Safety', <?php echo $accordionopenaccordionsafety ?>],
['Security', <?php echo $accordionopenaccordionsecurity ?>],
['Fuel Consumption', <?php echo $accordionopenaccordionfuelconsumption ?>],
['Performance', <?php echo $accordionopenaccordionperformance ?>],
['Wheels', <?php echo $accordionopenaccordionwheels ?>],
['General', <?php echo $accordionopenaccordiongeneral ?>],
['Technical', <?php echo $accordionopenaccordiontechnical ?>],
['Emissions', <?php echo $accordionopenaccordionemissions ?>],
['Engine and Drivetrain', <?php echo $accordionopenaccordionengineanddrivetrain ?>],
['Tyres', <?php echo $accordionopenaccordiontyres ?>],
['Trim', <?php echo $accordionopenaccordiontrim ?>],
['Weight and Capacities', <?php echo $accordionopenaccordionweightandcapacities ?>],
['Vehicle Dimensions', <?php echo $accordionopenaccordionvehicledimensions ?>],
['Packs', <?php echo $accordionopenaccordionpacks ?>],
['Interior Features', <?php echo $accordionopeninteriorfeatures ?>]
]);
var options = {
title: 'My Daily Activities',
};
options.chartArea = {left: 0, 'width': '90%', 'height': '90%'}
var chart = new google.visualization.PieChart(document.getElementById('pieChartVehicle'));
chart.draw(data, options);
}
</script>
<!-- Bodystyles Pie -->
<script>
google.charts.load('current', {'packages': ['corechart']});
google.charts.setOnLoadCallback(drawChartBodyInt);
function drawChartBodyInt() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Used Car Search');
data.addColumn('number', 'Click Count');
data.addRows([
['Hatchback', <?php echo $hatchback ?>],
['Estate', <?php echo $estate ?>],
['Suv', <?php echo $suv ?>],
['4x4', <?php echo $fourxfour ?>],
['Mpv', <?php echo $mpv ?>],
['Saloon', <?php echo $saloon ?>],
['Sport', <?php echo $sport ?>],
['Convertible', <?php echo $convertible ?>],
['Coupes', <?php echo $coupes ?>],
['Pickup', <?php echo $pickup ?>],
['Crewvan', <?php echo $crewvan ?>],
['Doublecab', <?php echo $doublecab ?>],
['Minibus', <?php echo $minibus ?>],
['Tipper', <?php echo $tipper ?>],
['Dropside', <?php echo $dropside ?>],
['Luton', <?php echo $luton ?>],
['Chassis', <?php echo $chassis ?>],
['Box', <?php echo $box ?>],
['Curtainslider', <?php echo $curtainslider ?>],
['Platformcab', <?php echo $platformcab ?>],
['Refridgerated', <?php echo $refridgerated ?>],
['Freezer', <?php echo $freezer ?>],
]);
var options = {
title: 'My Daily Activities',
};
options.chartArea = {left: 0, 'width': '90%', 'height': '90%'}
var chart = new google.visualization.PieChart(document.getElementById('pieChartBody'));
chart.draw(data, options);
}
</script>
<!-- Options Interest Pie -->
<script>
google.charts.load('current', {'packages': ['corechart']});
google.charts.setOnLoadCallback(drawChartOptInt);
function drawChartOptInt() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Used Car Search');
data.addColumn('number', 'Click Count');
data.addRows([
['Air Conditioning', <?php echo $airconditioning ?>],
['Bluetooth', <?php echo $bluetooth ?>],
['Sat Nav', <?php echo $satnav ?>],
['Cruise Control', <?php echo $cruisecontrol ?>],
['Parking Sensors', <?php echo $parkingsensors ?>],
['Heated Windscreen', <?php echo $heatedwindscreen ?>],
['Cd Player', <?php echo $cdplayer ?>],
['Dab Radio', <?php echo $dabradio ?>],
['Aux Input', <?php echo $auxinput ?>],
['Park Assist', <?php echo $parkassist ?>],
['Phone Nav', <?php echo $phonenav ?>],
['Heated Seats', <?php echo $heatedseats ?>],
['Parking Camera', <?php echo $parkingcamera ?>],
['Leather Interior', <?php echo $leatherinterior ?>],
['Keyles Sentry', <?php echo $keylessentry ?>],
['Dvd Player', <?php echo $dvdplayer ?>],
['Metallic Paint', <?php echo $metallicpaint ?>],
['Mp3 Player', <?php echo $mp3player ?>],
['Spoiler', <?php echo $spoiler ?>]
]);
var options = {
title: 'My Daily Activities',
};
options.chartArea = {left: 0, 'width': '90%', 'height': '90%'}
var chart = new google.visualization.PieChart(document.getElementById('pieChartOptIn'));
chart.draw(data, options);
}
</script>
<!-- Image Interest Pie -->
<script>
google.charts.load('current', {'packages': ['corechart']});
google.charts.setOnLoadCallback(drawChartImgInt);
function drawChartImgInt() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Used Car Search');
data.addColumn('number', 'Click Count');
data.addRows([
['Interior', <?php echo $interiorinterests ?>],
['Exterior', <?php echo $exteriorinterests ?>],
['Features', <?php echo $featuresinterests ?>],
['All', <?php echo $allinterests ?>],
['Images Only', <?php echo $imagesonlyinterests ?>]
]);
var options = {
title: 'My Daily Activities',
};
options.chartArea = {left: 0, 'width': '90%', 'height': '90%'}
var chart = new google.visualization.PieChart(document.getElementById('pieChartImgInt'));
chart.draw(data, options);
}
</script>
@stop
最佳答案
$records = UsedCarsAnalytics::selectRaw('COUNT(id) as count, type')->groupBy('type')->get();
您将获得每种类型的带有 count 的对象。
foreach($records as $record){
echo $record->type." - ".$record->count."<br>";
}
/* You will get someting like:
search-model-dropdown - 62
search-manufacturer-dropdown - 113
.
.
.
*/
然后你可以创建变量......你需要什么。重要的是,您将只有一个 SQL 选择,但它应该会加快速度。
关于php - SQL/Laravel 构建查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43541342/
SQL、PL-SQL 和 T-SQL 之间有什么区别? 谁能解释一下这三者之间的区别,并提供每一个的相关使用场景? 最佳答案 SQL 是一种对集合进行操作的查询语言。 它或多或少是标准化的,几乎所有关
这个问题已经有答案了: What is the difference between SQL, PL-SQL and T-SQL? (6 个回答) 已关闭 9 年前。 我对 SQL 的了解足以完成我的
我在数据库中有一个 USER 表。该表有一个 RegistrationDate 列,该列有一个默认约束为 GETDATE()。 使用 LINQ 时,我没有为 RegistrationDate 列提供任
我有一个可能属于以下类型的字符串 string expected result 15-th-rp 15 15/12-rp 12 15-12-th
很难说出这里问的是什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或言辞激烈,无法以目前的形式合理回答。如需帮助澄清此问题以便可以重新打开,visit the help center . 9年前关闭
我有一个存储过程(称为 sprocGetArticles),它从文章表中返回文章列表。这个存储过程没有任何参数。 用户可以对每篇文章发表评论,我将这些评论存储在由文章 ID 链接的评论表中。 有什么方
我目前正在做一个 *cough*Oracle*cough* 数据库主题。讲师介绍embedded SQL作为让其他语言(例如 C、C++)与(Oracle)数据库交互的方式。 我自己做了一些数据库工作
SQL Server 中 SQL 语句的最大长度是多少?这个长度是否取决于 SQL Server 的版本? 例如,在 DECLARE @SQLStatement NVARCHAR(MAX) = N'S
这个问题已经有答案了: Simple way to transpose columns and rows in SQL? (9 个回答) 已关闭 8 年前。 CallType
预先感谢您对此提供的任何帮助。 假设我有一个查询,可以比较跨年的数据,从某个任意年份开始,永无止境(进入 future ),每年同一时期直到最后一个完整的月份(其特点是一月数据永远不会显示至 2 月
我在数据库中有一个 USER 表。该表有一个 RegistrationDate 列,该列的默认约束为 GETDATE()。 使用 LINQ 时,我没有为 RegistrationDate 列提供任何数
下面是我试图用来检查存储过程是否不存在然后创建过程的 sql。它会抛出一个错误:Incorrect syntax near the keyword 'PROCEDURE' IF NOT EXISTS
我有一个同事声称动态 SQL 在许多情况下比静态 SQL 执行得更快,所以我经常看到 DSQL 到处都是。除了明显的缺点,比如在运行之前无法检测到错误并且更难阅读,这是否准确?当我问他为什么一直使用
来自 lobodava 的动态 SQL 查询是: declare @sql nvarchar(4000) = N';with cteColumnts (ORDINAL_POSITION, CO
使用 SQL Server 中的存储过程执行动态 SQL 命令的现实优点和缺点是什么 EXEC (@SQL) 对比 EXEC SP_EXECUTESQL @SQL ? 最佳答案 sp_executes
我有这个有效的 SQL 查询: select sum(dbos.Points) as Points, dboseasons.Year from dbo.StatLines dbos i
我正在调试一些构建成功运行的 SQL 命令的代码。 然而,在查询结束时,查询结果似乎被写入了一个文本文件。 完整的查询如下 echo SELECT DATE,DATETABLE,DATE,APPDAT
我有一些创建表的 .sql 文件(MS SQL 数据库): 表_1.sql: IF OBJECT_ID (N'my_schema.table1', N'U') IS NOT NULL DROP TAB
我写了下面的 SQL 存储过程,它一直给我错误@pid = SELECT MAX(... 整个过程是: Alter PROCEDURE insert_partyco @pname varchar(20
我在 SQL Server 2005 中有包含两列 Fruit 和 Color 的表,如下所示 Fruit Colour Apple Red Orange
我是一名优秀的程序员,十分优秀!