我不知道为什么我不能让下面的工作:
DB::table('twitter_hashtags')->paginate(5);
每次我得到(第二个数字往往不同)
Allowed memory size of 134217728 bytes exhausted (tried to allocate 95735352 bytes)
我尝试使用as in(18776710),但没有任何区别
DB::connection()->disableQueryLog();
删除-
当我尝试:
DB::select('SELECT * FROM twitter_hashtags');
它工作正常,但是我不能在分页选项中使用构建。
有人有什么建议吗?
表twitter_hashtags目前有5500条记录。一个id,tweet_id和主题标签都保存了,所以不可能是表太大的问题。
表的大小:
Data 384,0 KB
Index 464,0 KB
Total 848,0 KB
使现代化
应要求提供更多信息
这就是行动
public function getHashtags()
{
DB::connection()->disableQueryLog(); // With or without does not make a difference
$retweets = DB::table('twitter_hashtags')->paginate(10);
// Show the page
return View::make('twitter/retweets', compact('retweets'));
}
如你所见,我使用了转发的视图,问题也出现在转发中,或者几乎任何其他表,我试图从这种方式获取数据。
“观点”
我用来创建表的迁移
public function up()
{
Schema::create('twitter_hashtags', function($table)
{
// Basic run information
$table->increments('id');
$table->string('status_id')->index();
$table->string('hashtag')->index();
// Misc.
$table->timestamps();
});
}
当内存限制提高到256M时,这些是响应的前100行左右
Illuminate\Database\Query\Builder Object
(
[connection:protected] => Illuminate\Database\MySqlConnection Object
(
[pdo:protected] => PDO Object
(
)
[queryGrammar:protected] => Illuminate\Database\Query\Grammars\MySqlGrammar Object
(
[wrapper:protected] => `%s`
[selectComponents:protected] => Array
(
[0] => aggregate
[1] => columns
[2] => from
[3] => joins
[4] => wheres
[5] => groups
[6] => havings
[7] => orders
[8] => limit
[9] => offset
[10] => unions
)
[tablePrefix:protected] =>
)
[schemaGrammar:protected] =>
[postProcessor:protected] => Illuminate\Database\Query\Processors\Processor Object
(
)
[events:protected] => Illuminate\Events\Dispatcher Object
(
[container:protected] => Illuminate\Foundation\Application Object
(
[booted:protected] => 1
[bootingCallbacks:protected] => Array
(
[0] => Closure Object
(
[parameter] => Array
(
[$app] =>
)
)
[1] => Closure Object
(
[static] => Array
(
[instance] => Illuminate\Log\LogServiceProvider Object
(
[defer:protected] => 1
[app:protected] => Illuminate\Foundation\Application Object
*RECURSION*
)
)
)
[2] => Closure Object
(
[static] => Array
(
[instance] => Illuminate\Mail\MailServiceProvider Object
(
[defer:protected] => 1
[app:protected] => Illuminate\Foundation\Application Object
*RECURSION*
)
)
)
[3] => Closure Object
(
[static] => Array
(
[instance] => Illuminate\Queue\QueueServiceProvider Object
(
[defer:protected] => 1
[app:protected] => Illuminate\Foundation\Application Object
*RECURSION*
)
)
)
[4] => Closure Object
(
[static] => Array
(
[instance] => Illuminate\Translation\TranslationServiceProvider Object
(
[defer:protected] => 1
[app:protected] => Illuminate\Foundation\Application Object
*RECURSION*
)
)
)
更新2
按要求。以下是回应:
Array
(
[total] => 5689
[per_page] => 5
[current_page] => 1
[last_page] => 1138
[from] => 1
[to] => 5
[data] => Array
(
[0] => stdClass Object
(
[id] => 1
[status_id] => 384992474579484672
[hashtag] => Twenterand
[created_at] => 2013-10-01 11:00:02
[updated_at] => 2013-10-01 11:00:02
)
[1] => stdClass Object
(
[id] => 2
[status_id] => 384992323190280192
[hashtag] => Twenterand
[created_at] => 2013-10-01 11:00:03
[updated_at] => 2013-10-01 11:00:03
)
[2] => stdClass Object
(
[id] => 3
[status_id] => 384989174014545921
[hashtag] => PVDA
[created_at] => 2013-10-01 11:00:03
[updated_at] => 2013-10-01 11:00:03
)
[3] => stdClass Object
(
[id] => 4
[status_id] => 384988499188801536
[hashtag] => GR2014
[created_at] => 2013-10-01 11:00:03
[updated_at] => 2013-10-01 11:00:03
)
[4] => stdClass Object
(
[id] => 5
[status_id] => 384986184092356608
[hashtag] => GR2014
[created_at] => 2013-10-01 11:00:03
[updated_at] => 2013-10-01 11:00:03
)
)
)
)
)
更新3
这里是我用于GetStatus的代码
public function getStatuses()
{
// Get all the paginated statuses
$statuses = DB::table('twitter_statuses')
->select('status_id', 'text', 'user_screen_name','datetime','place')
->orderBy('datetime', 'DESC')
->paginate(10);
// Show the page
return View::make('twitter/statuses', compact('statuses'));
}
和完整的视图文件
@extends('layouts/default')
{{-- Page title --}}
@section('title')
Twitter Statuses ::
@parent
@stop
{{-- Page content --}}
@section('content')
<h1>Twitter Statuses</h1>
<div class="container">
<table class="table">
<tr>
<th>Datum</th>
<th>Gebruiker</th>
<th>Tweet</th>
<th>Locatie</th>
</tr>
<?php foreach ($statuses as $status): ?>
<tr>
<td>{{ $status->datetime; }}</td>
<td><?php echo $status->user_screen_name; ?></td>
<td><?php echo $status->text; ?></td>
<td><?php echo $status->place; ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php echo $statuses->links(); ?>
</div>
@stop
我也有同样的问题。解决方案很简单:只需添加-
public function getStatuses()
{
// Get all the paginated statuses
$statuses = DB::table('twitter_statuses')
->select('status_id', 'text', 'user_screen_name','datetime','place')
->orderBy('datetime', 'DESC')
->paginate(10)
->get()
;
// Show the page
return View::make('twitter/statuses', compact('statuses'));
}
我有以下代码: 不同的文件: 由于我编写了Mail()函数,因此出现以下错误: 致命错误:允许的内存大小134217728字节已用尽(尝试分配65488字节)
在同一个系统中,我可以调用数据库,没有问题,但在某些情况下(与最大的表),我得到 “PHP致命错误:第311行的/home/forge/sximo.sp-marketing.com/vendor/laravel/framework/src/light/Database/Connection.PHP中允许的内存大小为536870912字节(尝试分配32字节) 我调试了代码,问题是一个基本查询: 当我
我有一个PHP的问题,我只是想尝试调用方法 我得到错误: 致命错误:允许的内存大小为134217728字节耗尽(试图分配1字节)在C:\xampp\htdocs\aa-acc\包括\Produk_Method.php在第13行 我尝试过这个答案:在php中允许内存大小为33554432字节(尝试分配43148176字节) 我仍然得到这个错误: 致命错误:内存不足(分配1881931776)(尝试分
以下是完整的错误: 致命错误:允许内存大小为134217728字节耗尽(尝试分配131072字节) /sites/apps/seller/www/application/libraries/Excel/PHPExcel/CachedObjectStorage/CacheBase.php行173 这是mu代码: 我使用codeigniter框架和phpexcel库。非常感谢。
可能重复: php中允许的内存大小为33554432字节(尝试分配43148176字节) 我在执行代码时遇到以下错误。 尝试了
我正在尝试运行artisan make:controller。 我有一个问题: 我试图增加