AmarjaPatil4
AmarjaPatil4

Reputation: 1650

SQLSTATE[42S02]: Base table or view not found: 1146 Table

I am creating laravel's registration part. My table name is 'owner' and in code I wrote 'owner' as a table name, but still when I try to submit the registration form I am getting the error page as,

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'engage.owners' doesn't exist (SQL: insert into owners.....

As there is no owners table in my engage database, I don't know why it's trying to insert into owners table rather than owner table.

Upvotes: 2

Views: 3887

Answers (2)

Yaroslav Zinchenko
Yaroslav Zinchenko

Reputation: 63

I also faced the same problem during application deployment to hosting, although everything worked fine on my local server. It turned out that I had a SELECT from the database in the code that was taking data from the ARTISTS table. And in my database, my table was written as artists (in small letters). Perhaps this is a MySQL problem (in my case), since I have version 8 installed locally, and on the hosting it is 5.6.

There is also a strict mode in MySQL that you can turn off to avoid this problem.

Upvotes: 0

vardius
vardius

Reputation: 6546

Accourding to the docs: http://laravel.com/docs/5.1/eloquent

you can change it like this:

namespace App;

use Illuminate\Database\Eloquent\Model;

class Flight extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'my_flights';
}

Keep in mind i never worked with laravel.

Upvotes: 3

Related Questions