在 laravel 中加入 table - 分页不起作用
Join table in laravel - Pagination not working
//get all the data of both table
foreach($tables as $table){
$table_history = $table.'_history';
$result[] = DB::table($table)->join($table_history, $table.user_id, '=',$table_history.user_id )->paginate(5);
}
当我尝试时
<?php echo $result->links(); ?>
它没有 return 任何东西。
并且还试图print_r结果
<?php print_r($result); ?>
它return编辑:
Illuminate\Pagination\Paginator Object ( [factory:protected] => Illuminate\Pagination\Factory Object ( [request:protected] => Illuminate\Http\Request Object ( [json:protected] => [sessionStore:protected] => [attributes] => Symfony\Component\HttpFoundation\ParameterBag Object ( [parameters:protected] => Array ( ) ) [request] => Symfony\Component\HttpFoundation\ParameterBag Object ( [parameters:protected] => Array ( ) ) [query] => Symfony\Component\HttpFoundation\ParameterBag Object ( [parameters:protected] => Array ( ) ) [server] => Symfony\Component\HttpFoundation\ServerBag Object ( [parameters:protected] => Array ( [DOCUMENT_ROOT] => C:\xampp\htdocs\system101\public [REMOTE_ADDR] => ::1 [REMOTE_PORT] => 53241 [SERVER_SOFTWARE] => PHP 5.4.7 Development Server [SERVER_PROTOCOL]
我试着把变量变成数组:
$result[] = DB::table('user')->join('position', user.user_id, '=',position.user_id )->get();
它显示了所有需要的数据。但是,我还是把它改成了 ->paginate(5)
它 return 和上面的一样。
如何显示分页链接?或者有没有其他方法可以实现分页?
Join 仅接受字符串参数
Laravel 加入语法
join(string $table, string $one, string $operator = null, string $two = null, string $type = 'inner', bool $where = false)
修复查询中的数据库属性字符串
$result = DB::table('user')
->join('position', 'user.user_id', '=', 'position.user_id')->paginate(5);
此外...
foreach($tables as $table):
$table_history = $table.'_history';
$result = DB::table($table)
->join("$table_history", "$table.user_id", '=', "$table_history.user_id")
->paginate(5);
endforeach;
//get all the data of both table
foreach($tables as $table){
$table_history = $table.'_history';
$result[] = DB::table($table)->join($table_history, $table.user_id, '=',$table_history.user_id )->paginate(5);
}
当我尝试时
<?php echo $result->links(); ?>
它没有 return 任何东西。
并且还试图print_r结果
<?php print_r($result); ?>
它return编辑:
Illuminate\Pagination\Paginator Object ( [factory:protected] => Illuminate\Pagination\Factory Object ( [request:protected] => Illuminate\Http\Request Object ( [json:protected] => [sessionStore:protected] => [attributes] => Symfony\Component\HttpFoundation\ParameterBag Object ( [parameters:protected] => Array ( ) ) [request] => Symfony\Component\HttpFoundation\ParameterBag Object ( [parameters:protected] => Array ( ) ) [query] => Symfony\Component\HttpFoundation\ParameterBag Object ( [parameters:protected] => Array ( ) ) [server] => Symfony\Component\HttpFoundation\ServerBag Object ( [parameters:protected] => Array ( [DOCUMENT_ROOT] => C:\xampp\htdocs\system101\public [REMOTE_ADDR] => ::1 [REMOTE_PORT] => 53241 [SERVER_SOFTWARE] => PHP 5.4.7 Development Server [SERVER_PROTOCOL]
我试着把变量变成数组:
$result[] = DB::table('user')->join('position', user.user_id, '=',position.user_id )->get();
它显示了所有需要的数据。但是,我还是把它改成了 ->paginate(5)
它 return 和上面的一样。
如何显示分页链接?或者有没有其他方法可以实现分页?
Join 仅接受字符串参数
Laravel 加入语法
join(string $table, string $one, string $operator = null, string $two = null, string $type = 'inner', bool $where = false)
修复查询中的数据库属性字符串
$result = DB::table('user')
->join('position', 'user.user_id', '=', 'position.user_id')->paginate(5);
此外...
foreach($tables as $table):
$table_history = $table.'_history';
$result = DB::table($table)
->join("$table_history", "$table.user_id", '=', "$table_history.user_id")
->paginate(5);
endforeach;