我在laravel中的控制器中使用了自定义查询,这是我控制器中的代码:
public function c_viewSystemUser()
{
$title = "View System Users";
$jSu = DB::select(DB::raw("SELECT dbo_systemusers.SystemUserID,dbo_systemtypes.SystemType, dbo_systemusers.SystemUserName INNER JOIN dbo_systemtypes ON dbo_systemusers.SystemUserTypeID = dbo_systemtypes.SystemUserTypeID"));
return View::make('ssims.view_systemUser',compact('title','jSu'));
}
我想在我的刀片文件view_systemUser
中显示其结果这是我在视图中的代码:
@if ($jSu)
<table class="table table-striped table-hover" id="detailTable">
<thead>
<tr>
<th>System User ID</th>
<th>SystemUser Type ID</th>
<th>System UserName</th>
<th>System User Description</th>
</tr>
</thead>
<tbody>
@foreach ($jSu as $vu)
<tr>
<td>{{ $vu->dbo_systemusers.SystemUserID }}</td>
<td>{{ $vu->dbo_systemtypes.SystemType }}</td>
<td>{{ $vu->dbo_systemusers.SystemUserName}}</td>
<td>{{ $vu->dbo_systemusers.SystemUserDescription}}</td>
</tr>
@endforeach
</tbody>
</table>
我有一个错误:
未定义属性:stdClass :: $ dbo_systemusers(查看: C:\ XAMPP \ htdocs中\ laravel3 \应用\视图\ SSIMS \ view_systemUser.blade.php)
有什么建议吗?
答案 0 :(得分:2)
试试这个:
#import "ConfigurableButton.h"
@implementation ConfigurableButton
//Sets one of the font properties, depending on which state was passed
- (void) setFont:(UIFont *)font forState:(NSUInteger)state
{
switch (state) {
case UIControlStateNormal:
{
self.normalFont = font;
break;
}
case UIControlStateHighlighted:
{
self.highlightedFont = font;
break;
}
case UIControlStateDisabled:
{
self.disabledFont = font;
break;
}
case UIControlStateSelected:
{
self.selectedFont = font;
break;
}
default:
{
self.normalFont = font;
break;
}
}
}
/**
* Overrides layoutSubviews in UIView, to set the font for the button's state,
* before calling [super layoutSubviews].
*/
- (void) layoutSubviews
{
NSUInteger state = self.state;
switch (state) {
case UIControlStateNormal:
{
[self setTitleFont:_normalFont];
break;
}
case UIControlStateHighlighted:
{
[self setTitleFont:_highlightedFont];
break;
}
case UIControlStateDisabled:
{
[self setTitleFont:_disabledFont];
break;
}
case UIControlStateSelected:
{
[self setTitleFont:_selectedFont];
break;
}
default:
{
[self setTitleFont:_normalFont];
break;
}
}
[super layoutSubviews];
}
/**
* Private
*
* Convenience method that falls back to the System font,
* if no font is configured.
*/
- (void) setTitleFont:(UIFont *)font
{
if (!font) {
font = [UIFont systemFontOfSize:15];
}
self.titleLabel.font = font;
}
@end
答案 1 :(得分:1)
您忘记使用dbo_systemtypes加入dbo_systemusers。 试试这段代码
@foreach ($jSu as $key => $vu)
<tr>
<td>{{ $vu->SystemUserID }}</td>
<td>{{ $vu->SystemType }}</td>
<td>{{ $vu->SystemUserName}}</td>
<td>{{ $vu->SystemUserDescription}}</td>
</tr>
@endforeach
在浏览页面上试试这个
SELECT dbo_systemusers.SystemUserID,dbo_systemtypes.SystemType, dbo_systemusers.SystemUserName from dbo_systemusers INNER JOIN dbo_systemtypes ON dbo_systemusers.SystemUserTypeID = dbo_systemtypes.SystemUserTypeID