Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How is the ORM get Table in database ?
  • Help me!

    i have a class Model as below:
    class Model_Book extends \Orm\Model {
      protected static $_properties = array(
          'id',
          'title',
          'quantity',
          'binding',
          'created_at',
          'updated_at',
      );
      protected static $_observers = array(
          'Orm\Observer_CreatedAt' => array(
              'events' => array('before_insert'),
              'mysql_timestamp' => false,
          ),
          'Orm\Observer_UpdatedAt' => array(
              'events' => array('before_save'),
              'mysql_timestamp' => false,
          ),
      );
    }

    And table name "books"
    With class model and table name are "Model_Book" and "books" it work.

    But when i change table name "books"  => "book" it not working.

    I don't understand Orm model get table name, where?
    Please help me.

    Thank for your help

  • Put this line in your model :

    protected static $_table_name = 'book';

    By default, ORM model use the model name in plurial for set the table name
  • @syntaxlb. Thank you very much.

Howdy, Stranger!

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

In this Discussion