PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, February 3, 2022

[FIXED] LARAVEL - Base table or view not found: 1146 Table doesn't exist (SQL: select * from )

 February 03, 2022     laravel, laravel-5, model, php     No comments   

Issue

I have a Mysql database minho.win and a table called utilizadores.

I created a model class php artisan make:model Utilizador

When I do php artisan tinker and then do App\Utilizador::all() I get this error:

Illuminate\Database\QueryException with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'minho.win.utilizadors' doesn't exist (SQL: select * from utilizadors)'

Why is it looking for a table named utilizadors? How can I make it look for the right table - utilizadores?


Solution

You can specify the table in your model:

class Utilizador extends Model {
    protected $table = 'utilizadores';
}

https://laravel.com/docs/5.5/eloquent#eloquent-model-conventions



Answered By - Mathew Tinsley
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing