eloquen and php active record cant find table because additional table suffix 's'

188 Views Asked by At

i just get php active record or eloquen from laravel running on codeigniter. first attempt create model it's run well, but after that i got this following error:

Type: Illuminate\Database\QueryException

Message: SQLSTATE[42S02]: Base table or view not found: 1146 Table dog.ids' doesn't exist (SQL: select * from ids)

so for get it running i need to change every table in database with addition suffix 's' but keep model name without suffix 's'.

for example:
for model id

class id extends ActiveRecords/Model{
}

need tabe ids.
so how to keep table have the same name with model?
i don't understand what really happened. both library uses pdo for bridging data.


ps : sorry for my really bad english

1

There are 1 best solutions below

3
On

There are certain conventions in phpactiverecord, like the whole plural thing you refer to. Luckily you can override them. This way you don't need to change your database.

class id extends ActiveRecords/Model{
    static $table_name = 'id';
}

see: http://www.phpactiverecord.org/projects/3/wiki/Conventions