Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
How is the ORM get Table in database ?
vuongmaopro
July 2013
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
Syntaxlb
July 2013
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
vuongmaopro
August 2013
@syntaxlb
. Thank you very much.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Syntaxlb
July 2013
vuongmaopro
August 2013