Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Fuel\Core\Database_Exception [ Error ]: SQLSTATE[42S02]: Base table or view not found
  • i am beginner of learning fuelphp
    i have a problem.here
    Table 'dbname.categories' doesn't exist with query: "SELECT `t0`.`id` AS `t0_c0`, `t0`.`name` AS `t0_c1`, `t0`.`sort_order` AS `t0_c2`, `t0`.`delete_flag` AS `t0_c3`, `t0`.`updated_at` AS `t0_c4` FROM `categories` AS `t0` ORDER BY `t0`.`name` ASC LIMIT 10 OFFSET 0"
    my datables in a table name is category not categories
    i have a confuse about this case
    pls explain about this case
    here my model category

    class Model_Category extends \Orm\Model {

        protected static $_properties = array(
            'id',
            'name',
            'sort_order',
            'delete_flag',
            'updated_at',
        );
      

    }
  • If you don't specify the models table name, it will be determined from the model name. And the Fuel rule is that models are singular, table names are plural. Hence "categories" from "Model_Category".

    If you want to override this mechanism, define the tablename:

    protected static $_table_name = 'category';

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion