亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

未找到基表或視圖:1146 表 'xyz.testimonials' 不存在

未找到基表或視圖:1146 表 'xyz.testimonials' 不存在

PHP
冉冉說 2022-01-02 16:02:45
我不是 Laravel 的專家。剛開始做web開發。我被要求對從 c Panel 下載的現有項目進行更改。在服務器上,該項目運行良好。但是下載后我收到以下錯誤并且不太確定發生了什么。SQLSTATE[42S02]:未找到基表或視圖:1146 表 'xyz.testimonials' 不存在(SQL:select * from testimonials)下載項目后,我可以進行以下操作php artisan 緩存:清除作曲家更新php工匠遷移php工匠數據庫:種子下面的TestimonialController.php文件<?phpnamespace App\Http\Controllers;use Illuminate\Http\Request;use App\Testimonial;class TestimonialController extends Controller{    public function index()    {        $testimonials = Testimonial::all();        return view('dashboard.testimonials.index')->withTestimonials($testimonials);    }    public function create()    {        return view('dashboard.testimonials.create');    }    public function store(Request $request)    {        $request->validate(['testimonial_text'=>'required']);        $testimonial = Testimonial::create($request->all());        if($testimonial)        {            $this->success('Testimonial added successfully');        }        else        {            $this->error();        }        return redirect()->back();    }    public function edit(Testimonial $testimonial)    {        return view('dashboard.testimonials.edit')->withTestimonial($testimonial);    }    public function update(Testimonial $testimonial,Request $request)    {        if($testimonial->update($request->all()))        {            $this->success('Testimonial Updated Successfully');        }        else        {            $this->error();        }        return redirect()->route('dashboard.testimonials.index');    }    public function destroy(Testimonial $testimonial)    {        if($testimonial->delete())        {            $this->success('Testimonial Deleted Successfully');        }        else        {            $this->error();        }        return redirect()->back();    }}感言.php<?phpnamespace App;use Illuminate\Database\Eloquent\Model;class Testimonial extends Model{    public $guarded = [];    public function allTestimonials()    {        return self::all();    }}
查看完整描述

2 回答

?
小怪獸愛吃肉

TA貢獻1852條經驗 獲得超1個贊

Laravel 中有兩種表定義方式。

  • 模型類名 (testimonial) = 單數和表名 (testimonials) = 復數,請檢查testimonials 您的數據庫中是否可用。每當你沒有定義 $table到模型中時,就意味著 Laravel 自動搜索表。

  • 您必須手動添加$table到模型文件中,如下所示。每當您不
    按照第一條規則以復數形式創建表名時。

    受保護的 $table = '推薦';


查看完整回答
反對 回復 2022-01-02
?
皈依舞

TA貢獻1851條經驗 獲得超3個贊

確保您的xyz數據庫中存在推薦表。如果您使用另一個名稱創建了表,那么您必須在模型中定義它。


比方說,您已將表名作為證明。然后在您的模型中,受保護的字段將是,


class Testimonial extends Model

{

    protected $table = 'testimonial';

}


查看完整回答
反對 回復 2022-01-02
  • 2 回答
  • 0 關注
  • 592 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號