我的查询如下:
$this->_data['news'] = PageContent::orderBy('created_at', 'desc')->where('category_id', 3)->where('status', 1)->first();
在我的index.blade.php文件中,数据以这样的方式显示:
@if(count($news) > 0)
<div class="post_list_content_unit col-sm-6">
<div class="feature-image">
<a href="{{URL::to('/')}}/about-us/news-event" class="entry-thumbnail">
<img width="370" height="260"
src="{{URL::to('Uploads/pageContents/'.$news->image)}}"
alt="{{$news->title}}">
</a>
</div>
<div class="post-list-content">
<div class="post_list_inner_content_unit">
<h3 class="post_list_title">
<a href="{{URL::to('/')}}/about-us/news-event"
rel="bookmark">{{$news->title}}</a>
</h3>
<div class="post_list_item_excerpt">
{!! str_limit($news->description, 300) !!}
</div>
</div>
</div>
</div>
@else
<div></div>
@endif
但是,它不是显示只有status = 1的记录,而是显示状态值为0的数据。
查询有问题吗?
答案 0 :(得分:2)
您可以将数组传递给<?php
// DEBUGGING
// Sample $region_mappings_string and $franchises_string are provided for debugging
$helpers = getHelpers();
$franchises_string = $helpers['franchises_string'];
$region_mappings_string = $helpers['region_mappings_string'];
$franchise_search = new FranchiseSearch;
$franchise_search->initialize($franchises_string, $region_mappings_string);
// $search_postal_code = $_POST['postal_code']; // Defaulted to 14410
// $search_results = $franchise_search->search($search_postal_code);
# What PHP version is this?
echo "\n";
echo 'Current PHP version: ' . phpversion();
// All logic goes in this class
class FranchiseSearch
{
// Receives string in CSV format
function initialize($franchises_string, $region_mappings_string)
{
// Assign $region_mappings
// Assign $franchises
}
// Should return an ordered array (by name) of franchises for this postal code with all their information
function search($postal_code)
{
// Postal code 14410 should find 3 locations.
// If sorted alphabetically, second location name is "Prohaska, Gibson and Rolfson"
// website: auto-service.co/yw-159-d
// city: Adams Basin
// state: NY
// Should return array of arrays
return array();
}
}
?>
方法:
where
答案 1 :(得分:0)
您可以通过在where子句中传递数组来实现两种方法:
$this->_data['news'] = DB::table('PageContent')
->orderBy('created_at', 'desc')
->where([
['category_id', '=', '3'],
['status', '=', '1'],
])->first();
或者
$this->_data['news'] = PageContent::orderBy('created_at', 'desc')
->where([
['category_id', '=', '3'],
['status', '=', '1'],
])->first();
答案 2 :(得分:-1)
你应该试试这个:
if (ConfirmMPIN.getText().toString().trim().equals(MPIN.getText().toString().trim() )) {
Toast.makeText(RegisterActivity.this, "Password Match", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(RegisterActivity.this, "Not Matched", Toast.LENGTH_LONG).show();
}
希望这对你有用!!!