在我简单的laravel应用程序中,我曾经从数据库中获取一些数据并将其传递给视图,我可以在其中循环显示数据。
在我的本地主机这工作得很好,但当我将脚本移动到主机时,所有数据都没有显示,它显示非常奇怪的巨大的Json数组
class CmsController extends BaseController{
protected $layout = 'layouts.master';
public function Index(){
$menus = array();
$data = Menus::where('CID','=',Config::get('company.CID'))->where('topmenu','=','0')->get();
foreach ($data as $k => $rec){
$menus[$k]['title'] = $rec->title;
$menus[$k]['url'] = $rec->url;
$count = Menus::where('CID','=',Config::get('company.CID'))->where('topmenu','=',$rec->ID)->count();
if($count != 0){
$menus[$k]['subs'] = Menus::where('CID','=',Config::get('company.CID'))->where('topmenu','=',$rec->ID)->get();
}
}
$slides = Sliders::find('138')->Slides()->where('CID','=',Config::get('company.CID'));
$this->layout->content = View::make('cms.index')->with('menus', $menus)->with('slides',$slides);
}
public function Content($name){
$data = Pages::where('CID','=',Config::get('company.CID'))->where('page_name','=',$name)->first();
return View::make('cms.page')->with('content', $data);
}
}
视图中的
@foreach($menus as $menu)
@if (!empty($menu['subs']))
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" data-target="#" href="#">{{$menu['title']}}</a>
<ul class="dropdown-menu">
@foreach($menu['subs'] as $sub)
<li><a href="{{$sub->url}}">{{$sub->title}}</a></li>
@endforeach
</ul>
</li>
@else
<li><a href="{{$menu['url']}}">{{$menu['title']}}</a></li>
@endif
@endforeach
这是输出的一小部分
object(Illuminate\Database\Eloquent\Relations\HasMany)#213 (5) { ["foreignKey":protected]=> string(34) "tbl_cms_sliders_imgs_new.slider_id" ["localKey":protected]=> string(2) "ID" ["query":protected]=> object(Illuminate\Database\Eloquent\Builder)#218 (6) { ["query":protected]=> object(Illuminate\Database\Query\Builder)#214 (23) { ["connection":protected]=> object(Illuminate\Database\MySqlConnection)#206 (17) { ["pdo":protected]=> object(PDO)#207 (0) { } ["readPdo":protected]=> NULL ["reconnector":protected]=> object(Closure)#212 (2) { ["this"]=> object(Illuminate\Database\DatabaseManager)#118 (4) { ["app":protected]=> object(Illuminate\Foundation\Application)#2 (16) { ["booted":protected]=> bool(true) ["bootingCallbacks":protected]=> array(0) { } ["bootedCallbacks":protected]=> array(2) { [0]=> object(Closure)#74 (2) { ["static"]=> array(2) { ["app"]=> *RECURSION* ["me"]=> object(Illuminate\View\ViewServiceProvider)#67 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } } ["this"]=> object(Illuminate\View\ViewServiceProvider)#67 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } } [1]=> object(Closure)#46 (1) { ["static"]=> array(2) { ["app"]=> *RECURSION* ["env"]=> string(10) "production" } } } ["finishCallbacks":protected]=> array(0) { } ["shutdownCallbacks":protected]=> array(0) { } ["middlewares":protected]=> array(0) { } ["serviceProviders":protected]=> array(12) { [0]=> object(Illuminate\Events\EventServiceProvider)#11 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [1]=> object(Illuminate\Exception\ExceptionServiceProvider)#15 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [2]=> object(Illuminate\Routing\RoutingServiceProvider)#26 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [3]=> object(Illuminate\Cookie\CookieServiceProvider)#48 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [4]=> object(Illuminate\Database\DatabaseServiceProvider)#51 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [5]=> object(Illuminate\Encryption\EncryptionServiceProvider)#56 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [6]=> object(Illuminate\Filesystem\FilesystemServiceProvider)#59 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [7]=> object(Illuminate\Session\SessionServiceProvider)#62 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [8]=> object(Illuminate\View\ViewServiceProvider)#67 (2) { ["app":protected]=> *RECURSION* ["defer":protected]=> bool(false) } [9]=> object(Illuminate\Workbench\WorkbenchServiceProvider)#75 (2) { ["defer":protected]=> bool(false) ["app":protected]=> *RECURSION* } [10]=> object(Codesleeve\AssetPipeline\AssetPipelineServiceProvider)#81 (2) { ["defer":protected]=> bool(false) ["app":protected]=> *RECURSION* } [11]=> object(Illuminate\Log\LogServiceProvider)#105 (2) { ["defer":protected]=> bool(true) ["app":protected]=> *RECURSION* } } ["loadedProviders":protected]=> array(12) { ["Illuminate\Events\EventServiceProvider"]=> bool(true) ["Illuminate\Exception\ExceptionServiceProvider"]=> bool(true) ["Illuminate\Routing\RoutingServiceProvider"]=> bool(true) ["Illuminate\Cookie\CookieServiceProvider"]=> bool(true) ["Illuminate\Database\DatabaseServiceProvider"]=> bool(true) ["Illuminate\Encryption\EncryptionServiceProvider"]=> bool(true) ["Illuminate\Filesystem\FilesystemServiceProvider"]=> bool(true) ["Illuminate\Session\SessionServiceProvider"]=> bool(true) ["Illuminate\View\ViewServiceProvider"]=> bool(true) ["Illuminate\Workbench\WorkbenchServiceProvider"]=> bool(true) ["Codesleeve\AssetPipeline\AssetPipelineServiceProvider"]=> bool(true) ["Illuminate\Log\LogServiceProvider"]=> bool(true) } ["deferredServices":protected]=> array(70) { ["artisan"]=> string(54) "Illuminate\Foundation\Providers\ArtisanServiceProvider" ["command.changes"]=> string(54) "Illuminate\Foundation\Providers\ArtisanServiceProvider" ["command.environment"]=> string(54) "Illuminate\Foundation\Providers\ArtisanServiceProvider" ["auth"]=> string(35) "Illuminate\Auth\AuthServiceProvider" ["cache"]=> string(37) "Illuminate\Cache\CacheServiceProvider" ["cache.store"]=> string(37) "Illuminate\Cache\CacheServiceProvider" ["memcached.connector"]=> string(37) "Illuminate\Cache\CacheServiceProvider" ["command.cache.clear"]=> string(37) "Illuminate\Cache\CacheServiceProvider" ["command.cache.table"]=> string(37) "Illuminate\Cache\CacheServiceProvider" ["command.session.database"]=> string(42) "Illuminate\Session\CommandsServiceProvider" ["command.command.make"]=> string(61)
如此巨大,以显示所有这一切 我检查了服务器并且有PHP 5.4.2并且安装了Mcrypt和Json库,当然还有PDO