dtla92562 2017-01-05 13:59
浏览 77
已采纳

Laravel Model不检索数据

Im using laravel to pull some log information from a database, but all of a sudden its stopped working, as in its not retrieving data and not returning anything. Im using vuejs to retrieve the data without page refresh, theres no problem on the front end because data can still be retrieved also in the chrome debug console its displaying as a 500 error.

Furthermore what i find weird is it works locally but not in production.

Example code of what works and what doesn't

 <?php

namespace App\Http\Controllers;

use App\Log;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class LogController extends Controller
{

    public function getLogData()
    {

          //This is the original code & it doesn't work in production! 
          //$data = Log::orderBy('id', 'DESC')->select('action', 'object_id', 'ip_address', 'user', 'time', 'date')->get();

        //This works! But only retrieves 1 row of information
        $data = Log::where('id', 1)->get();

        $data = str_replace('*', "<b>", $data);
        $data = str_replace('^', "</b>", $data);

        return $data;
    }

}

and heres the logs model, which shouldnt really affect anything but entering data into the database really but just incase anyone needs this information.

namespace App;

use Illuminate\Database\Eloquent\Model;

class Log extends Model
{
    protected $fillable = ['action', 'object_id', 'object_type', 'ip_address', 'user', 'time', 'date'];
}

Any help i get will be appreciated.

  • 写回答

2条回答 默认 最新

  • doujiu7704 2017-01-19 11:11
    关注

    The answer to this question can be found here in detail: Limit on amount of rows retrieved MySql, Laravel

    In short my Mysql query was pulling back more than my set limit of data due the the growing daily data of my logs table. Increased the limit and everything was working as usual.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路