本文整理汇总了PHP中Data::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::where方法的具体用法?PHP Data::where怎么用?PHP Data::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Data
的用法示例。
在下文中一共展示了Data::where方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getView
public function getView($unique)
{
//disable php timeout
set_time_limit(0);
$compare = Compare::where('unique', $unique)->first();
if (!$compare) {
return Redirect::to('compare/notfound');
}
$owner_id = Session::get('owner');
if (!$owner_id) {
$owner_id = str_random(10);
Session::put('owner', $owner_id);
}
$total_uploads = Data::where('compare_id', $unique)->count();
$owner_uploads = Data::where('owner_id', $owner_id)->where('compare_id', $unique)->count();
$other_uploads = Data::where('owner_id', '!=', $owner_id)->where('compare_id', $unique)->count();
//$total_uploaders = DB::select('select count(distinct owner_id) as count from data where compare_id = "'.$unique.'" ');
//$total_uploaders = $total_uploaders[0]->count;
$uploaders = DB::select('select distinct owner_id as owner_id from data where compare_id = "' . $unique . '" ');
$total_uploaders = count($uploaders);
$matches = 'n/a';
if ($total_uploaders == 2) {
$compare_data = DB::select("\n\t\t\t\tselect count(distinct data1.id) as count from \n\t\t\t\tdata as data1\n\t\t\t\tinner join\n\t\t\t\tdata as data2\n\t\t\t\ton data1.hash = data2.hash\n\t\t\t\twhere data1.compare_id = '" . $unique . "'\n\t\t\t\tand data1.owner_id = '" . $uploaders[0]->owner_id . "'\n\t\t\t\tand data2.owner_id = '" . $uploaders[1]->owner_id . "'\n\t\t\t");
$matches = $compare_data[0]->count;
}
$data = array('compare' => $compare, 'owner_uploads' => $owner_uploads, 'total_uploads' => $total_uploads, 'other_uploads' => $other_uploads, 'total_uploaders' => $total_uploaders, 'matches' => $matches);
return View::make('pages.compare.view', $data);
}
示例2: checkData
/**
* [checkRole description]
* @param [type] $role [description]
* @return [type] [description]
*/
public function checkData($data, $tablename)
{
$rs = Data::where('data_name', '=', $data)->where('table_name', '=', $tablename)->count();
if (isset($rs)) {
return $rs >= 1 ? false : true;
}
}
示例3: show
public function show($daysAgo)
{
$date = new Carbon\Carbon();
$date->subDays($daysAgo);
$sensors = Sensor::findMany(Data::where('timestamp', '>', $date->toDateTimeString())->distinct('sensor_id')->get(array('sensor_id'))->toArray());
$timestamps = Data::where('timestamp', '>', $date->toDateTimeString())->distinct('timestamp')->get(array('timestamp'));
return View::make("showGraph", ["daysAgo" => $daysAgo, "sensors" => $sensors, "timestamps" => $timestamps]);
}
示例4: createDashboardData
public static function createDashboardData($widget)
{
$dataArray = array();
$widgetObject = json_decode($widget->widget_source);
$current_value = Data::where('widget_id', $widget->id)->first()->data_object;
$current_value = str_replace('[%LINEBREAK%]', "\n", $current_value);
return [$current_value, $dataArray];
}
示例5: getIndex
public function getIndex($slug = '', $link_id = 0)
{
$debug = '';
$bmStart = microtime(true);
$perpage = intval(AppConfig::get('articles_per_page', 50));
$branch_prefixes = explode(',', AppConfig::get('branch_prefixes'));
$virtualPerpage = intval(AppConfig::get('virtual_per_page', 20));
$page = Page::where('slug', '=', $slug)->cacheTags('pages')->remember(1440)->first();
//$page = Page::where('slug', '=', Str::slug($slug))->first();
if (count($page) > 0) {
if ($filter_return = $this->authFilter($page->level)) {
return $filter_return;
}
if ($page->redirect) {
if (substr($page->redirect, 0, 1) == '{') {
$redir_arr = json_decode($page->redirect, true);
foreach ($redir_arr as $rlvl => $rslug) {
if (strpos($this->auth_lvl, $rlvl) !== false) {
return Redirect::to($rslug);
}
}
if (isset($redir_arr['def'])) {
return Redirect::to($redir_arr['def']);
}
} else {
return Redirect::to($page->redirect);
}
}
// get parameters from URL
$page->category = Input::has('category') ? Input::get('category') : ($page->default_category ? $page->default_category : false);
$page->section = Input::has('section') ? Input::get('section') : false;
$page->keywordInput = $page->ddkeycol ? Input::get('keyword') : '';
$page_vars = new stdClass();
// separate slug into branch and section, if applicable
$branch = $slug;
if ($page->link_slug) {
$branch = $page->link_slug;
}
$els = explode('/', $branch);
if (in_array($els[0], $branch_prefixes) && count($els) > 1) {
$branch = $els[0];
if (!$page->section) {
$page->section = $els[1];
}
}
$dta = normal::getTypes();
// get list of categories, if there is a "ddlist"
$categories = false;
$normalized = false;
if ($page->ddlist) {
$fld = $page->ddlist;
$catq = Link::where('branch', '=', $branch);
if ($page->section) {
$catq->where('section', '=', $page->section);
}
if ($dtp = array_search($fld, $dta)) {
$catq->join('data', 'data.rec_id', '=', 'links.id')->where('data.table_name', '=', 'links')->where('data.type', '=', $dtp)->whereNull('data.deleted_at');
$fld = 'data_body';
$normalized = true;
}
$category_model = $catq->groupBy($fld)->whereRaw('trim(`' . $fld . '`) != ""')->cacheTags('links')->remember(1440)->get(array($fld));
$categories = array('' => 'All');
foreach ($category_model as $category_item) {
$categories[$category_item->{$fld}] = $category_item->{$fld};
}
}
$links = false;
$columns = false;
// get list of links, specified by branch, section, category, state, and/or keyword
if ($page->linkdef || $link_id && $page->detaildef) {
// get column layout
$columns = Listcolumns::where('def', '=', $link_id ? $page->detaildef : $page->linkdef)->cacheTags('links')->remember(1440)->orderBy('listorder')->get();
$perlinkpage = intval(AppConfig::get('links_per_page', 50));
$query = new Link();
if ($link_id) {
$query = $query->where('id', '=', $link_id);
} else {
if ($page->section) {
$query = $query->where('section', '=', $page->section);
}
if ($page->category) {
if ($normalized) {
$query = $query->join('data AS d', 'd.rec_id', '=', 'links.id')->where('d.table_name', '=', 'links')->where('d.type', '=', $dtp)->whereNull('d.deleted_at');
}
$query = $query->where(isset($fld) ? $fld : ($page->section ? 'category' : 'section'), '=', $page->category);
}
if ($page->state) {
$query = $query->where('state', '=', $page->state);
}
if ($page->keywordInput) {
if ($page->keywordInput == "by_date") {
$query = $query->join('data AS d', 'd.rec_id', '=', 'links.id')->where('d.table_name', '=', 'links')->where('d.type', '=', 7)->whereNull('d.deleted_at');
$month = Input::get('themonth');
$year = Input::get('theyear');
$pfx = $year . '-' . $month;
$start_date = $pfx . '-01';
$end_date = $pfx . '-' . cal_days_in_month(CAL_GREGORIAN, $month, $year);
$query = $query->whereRaw('d.`data_body` BETWEEN ? AND ?', array($start_date, $end_date));
unset($page->keywordInput);
$page_vars->month = $month;
//.........这里部分代码省略.........
示例6: getEvents
public static function getEvents($user, $widget)
{
switch ($widget->widget_type) {
case 'google-spreadsheet-line-cell':
Log::info("google-spreadsheet-line-cell - widget_id - " . $widget['id']);
$widget_source = json_decode($widget['widget_source'], true);
$spreadsheetId = $widget_source['googleSpreadsheetId'];
$worksheetName = $widget_source['googleWorksheetName'];
# setup Google stuff
$client = GooglespreadsheetHelper::setGoogleClient();
$access_token = GooglespreadsheetHelper::getGoogleAccessToken($client, $user);
# init service
$serviceRequest = new DefaultServiceRequest($access_token);
ServiceRequestFactory::setInstance($serviceRequest);
$spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
# get spreadsheet
$spreadsheet = $spreadsheetService->getSpreadsheetById($spreadsheetId);
$worksheetFeed = $spreadsheet->getWorksheets();
# get worksheet
$worksheet = $worksheetFeed->getByTitle($worksheetName);
$listFeed = $worksheet->getListFeed();
# get celldata (first line = header, second line = content)
$listArray = array();
$values = array();
foreach ($listFeed->getEntries() as $entry) {
$values = $entry->getValues();
break;
# break, so we just the first line
}
$time = time();
$data = new Data();
$data->widget_id = $widget['id'];
$data->data_object = json_encode($values);
$data->date = date("Y-m-d", $time);
$data->timestamp = date('Y-m-d H:i:s', $time);
$data->save();
$widget->widget_ready = true;
$widget->save();
break;
# / case 'google-spreadsheet-line-cell'
# / case 'google-spreadsheet-line-cell'
case 'google-spreadsheet-line-column':
Log::info("google-spreadsheet-line-column - widget_id - " . $widget['id']);
$widget_source = json_decode($widget['widget_source'], true);
$spreadsheetId = $widget_source['googleSpreadsheetId'];
$worksheetName = $widget_source['googleWorksheetName'];
# setup Google stuff
$client = GooglespreadsheetHelper::setGoogleClient();
$access_token = GooglespreadsheetHelper::getGoogleAccessToken($client, $user);
# init service
$serviceRequest = new DefaultServiceRequest($access_token);
ServiceRequestFactory::setInstance($serviceRequest);
$spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
# get spreadsheet
$spreadsheet = $spreadsheetService->getSpreadsheetById($spreadsheetId);
$worksheetFeed = $spreadsheet->getWorksheets();
# get worksheet
$worksheet = $worksheetFeed->getByTitle($worksheetName);
# get feeddata (first line = header)
$listFeed = $worksheet->getListFeed();
foreach ($listFeed->getEntries() as $entry) {
$array = $entry->getValues();
$date = array_values($array)[0];
$value = array_values($array)[1];
# format date (from almost everything to Y-m-d)
$time = strtotime(trim(str_replace('.', '-', $date), '-'));
# have we saved data for this date?
$db_data = Data::where('widget_id', '=', $widget['id'])->where('date', '=', date("Y-m-d", $time));
if ($db_data->count() == 0) {
# nope, save it
$data = new Data();
$data->widget_id = $widget['id'];
$data->data_object = json_encode(array("value" => $value));
$data->date = date("Y-m-d", $time);
$data->timestamp = date('Y-m-d H:i:s', $time);
$data->save();
} else {
# yes, update it
$db_data->update(['data_object' => json_encode(array("value" => $value))]);
}
}
$widget->widget_ready = true;
$widget->save();
break;
# / case 'google-spreadsheet-line-column'
# / case 'google-spreadsheet-line-column'
case 'google-spreadsheet-text-cell':
Log::info("google-spreadsheet-text-cell - widget_id - " . $widget['id']);
$widget_source = json_decode($widget['widget_source'], true);
$spreadsheetId = $widget_source['googleSpreadsheetId'];
$worksheetName = $widget_source['googleWorksheetName'];
# setup Google stuff
$client = GooglespreadsheetHelper::setGoogleClient();
$access_token = GooglespreadsheetHelper::getGoogleAccessToken($client, $user);
# init service
$serviceRequest = new DefaultServiceRequest($access_token);
ServiceRequestFactory::setInstance($serviceRequest);
$spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
# get spreadsheet
$spreadsheet = $spreadsheetService->getSpreadsheetById($spreadsheetId);
//.........这里部分代码省略.........
示例7: getStdValues
static function getStdValues($type, $num = false, $placeh = false)
{
$va = Data::where('type', '=', $type)->orderBy('serial')->cacheTags('data')->remember(10080)->get();
return Display::makeDropdownArray($va, $num ? 'serial' : 'data_body', 'data_body', $placeh);
}
示例8: delDataAction
/**
* [delDataAction description]
* @param [type] $id [description]
* @return [type] [description]
*/
public function delDataAction($id)
{
Data::where('id', '=', $id)->delete();
return Redirect::to('data')->with('success', 'ชื่อข้อมูลรหัส = ' . $id . ' ลบทิ้งสำเร็จ');
}