Mysql Laravel SQL请求太大
我的目标 是为lambda用户创建一个简单的DB导航器。 为此,我有一个侧栏,其中包含所有DB table\u名称 在页面的中心,我需要数据。 以下是我的表名:Mysql Laravel SQL请求太大,mysql,laravel,routes,prefix,tablename,Mysql,Laravel,Routes,Prefix,Tablename,我的目标 是为lambda用户创建一个简单的DB导航器。 为此,我有一个侧栏,其中包含所有DB table\u名称 在页面的中心,我需要数据。 以下是我的表名: administratif equipement erreur etablissement interface_eth_routeur interface_eth_switch interface_ip_routeur latence mainteneur routeur_arp routeur_gsu routeur_su salle
administratif
equipement
erreur
etablissement
interface_eth_routeur
interface_eth_switch
interface_ip_routeur
latence
mainteneur
routeur_arp
routeur_gsu
routeur_su
salle_visio
site
switch
switch_arp
switch_module
下面是代码:
ROUTES.PHP
Route::get('navigateur_bdd', array('uses' => 'HomeController@navigateur_bdd', 'as' => 'navigateur_bdd'));
Route::get('navigateur_bdd/{table_name}', array('uses' => 'HomeController@bdd_show_table', 'as' => 'bdd_show_table'));
public function navigateur_bdd()
{
$table_name = DB::select('SHOW TABLES');
return View::make('navigateur_bdd', array('which_actif' => 3, 'table_name' => $table_name));
}
public function bdd_show_table($argument = NULL) {
$selected_table = DB::table($argument)->get();
$table_name = DB::select('SHOW TABLES');
return View::make('navigateur_bdd', array('which_actif' => 3, 'table_name' => $table_name, 'selected_table' => $selected_table));
}
<div id="sidebar-wrapper">
<ul class="sidebar-nav" id="sidebar">
<li class="well">Liste des tables</li>
@for ($i = 0 ; $i < count($table_name); $i ++)
<li><a href="{{ URL::to('navigateur_bdd/' . $table_name[$i]->Tables_in_MYNET)}}">{{$table_name[$i]->Tables_in_MYNET}}</a></li>
@endfor
</ul>
</div>
HOMECONTROLLER.PHP
Route::get('navigateur_bdd', array('uses' => 'HomeController@navigateur_bdd', 'as' => 'navigateur_bdd'));
Route::get('navigateur_bdd/{table_name}', array('uses' => 'HomeController@bdd_show_table', 'as' => 'bdd_show_table'));
public function navigateur_bdd()
{
$table_name = DB::select('SHOW TABLES');
return View::make('navigateur_bdd', array('which_actif' => 3, 'table_name' => $table_name));
}
public function bdd_show_table($argument = NULL) {
$selected_table = DB::table($argument)->get();
$table_name = DB::select('SHOW TABLES');
return View::make('navigateur_bdd', array('which_actif' => 3, 'table_name' => $table_name, 'selected_table' => $selected_table));
}
<div id="sidebar-wrapper">
<ul class="sidebar-nav" id="sidebar">
<li class="well">Liste des tables</li>
@for ($i = 0 ; $i < count($table_name); $i ++)
<li><a href="{{ URL::to('navigateur_bdd/' . $table_name[$i]->Tables_in_MYNET)}}">{{$table_name[$i]->Tables_in_MYNET}}</a></li>
@endfor
</ul>
</div>
当用户进入此区域时,第一个功能是主视图
当用户从主视图的侧栏单击表名称时,使用第二个函数
NAVIGATEUR\u BDD.BLADE.PHP
Route::get('navigateur_bdd', array('uses' => 'HomeController@navigateur_bdd', 'as' => 'navigateur_bdd'));
Route::get('navigateur_bdd/{table_name}', array('uses' => 'HomeController@bdd_show_table', 'as' => 'bdd_show_table'));
public function navigateur_bdd()
{
$table_name = DB::select('SHOW TABLES');
return View::make('navigateur_bdd', array('which_actif' => 3, 'table_name' => $table_name));
}
public function bdd_show_table($argument = NULL) {
$selected_table = DB::table($argument)->get();
$table_name = DB::select('SHOW TABLES');
return View::make('navigateur_bdd', array('which_actif' => 3, 'table_name' => $table_name, 'selected_table' => $selected_table));
}
<div id="sidebar-wrapper">
<ul class="sidebar-nav" id="sidebar">
<li class="well">Liste des tables</li>
@for ($i = 0 ; $i < count($table_name); $i ++)
<li><a href="{{ URL::to('navigateur_bdd/' . $table_name[$i]->Tables_in_MYNET)}}">{{$table_name[$i]->Tables_in_MYNET}}</a></li>
@endfor
</ul>
</div>
你在工作,但没有
"switch_arp"
routeur_su
routeur_gsu
你在工作,但没有
routeur_arp
经过调查,我在有很多行的表上有一个空白页(例如110000行)(尝试使用dd($selected_table));
所以这改变了我问题的标题:
如何将这110 000行存储在一个变量中?您可以使用Laravels功能。
它将您的数据拆分为多个页面,让您生成指向每个页面的链接
$selected_table = DB::table($argument)->paginate(100); // how many records you wan't on one page
然后在您的视图中,执行此操作以生成链接
{{ $table_name->links() }}
您能否首先通过在控制器的开头使用
dd($argument)
确保表名正确地传递给控制器?它是正确的。每个表名看起来都是正确的,如下所示:字符串“interface\u ip\u routeur”(长度=20),如果您使用$selected\u table
执行相同的操作,则不会显示前面提到的表。我明白了。它不会显示变量的表是有5000多行的表(switch_arp有110000行)我该怎么办?你认为它们有很多行吗?如果您执行此操作,会怎么样呢?DB::table($argument)->take(1000)->get()
?