Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Spelling in Oil Scaffold ?
  • Hi eveyone!
    I've noticed strange thing: i run scafflod:

    php oil g scaffold persons name:string phone:string ..etc
    php oil r migrate

    and this generate all files with right table/model etc name - "Controller_Persons", "Model_Person", etc.

    but, when i try to request controller: /persons - i get such error:

    Error - 2012-11-16 04:06:30 --> Error - SQLSTATE[42S02]: Base table or view not found: 1146 Table 'd2.people' doesn't exist with query: "SELECT `t0`.`id` AS `t0_c0`, `t0`.`name` AS `t0_c1`, `t0`.`link_vk` AS `t0_c2`, `t0`.`phone` AS `t0_c3`, `t0`.`email` AS `t0_c4`, `t0`.`address` AS `t0_c5`, `t0`.`description` AS `t0_c6`, `t0`.`city` AS `t0_c7`, `t0`.`created_at` AS `t0_c8`, `t0`.`updated_at` AS `t0_c9` FROM `people` AS `t0`" in D:\AppServ\OpenServerSites\d2.local\fuel\core\classes\database\pdo\connection.php on line 175

    for some reason, fuelphp trying to fetch database named "people" but not persons
  • The Oil generation convention is that table names are plural. And the plural for "person" is "people", not "persons".
  • so, generated migrations and models should point to 'people', not 'persons'
  • Correct.

    And to be compleet, the convention is that a model name is singular ("Person") as a model object deals with one person, the table and the controller names are plural ("People") as they deal with multiple persons.
  • Thi s sounds very interesting: I've used Rails for a while and there there is the convention to use the plural form (so "Persons", singular + s) unless you manually modify it.

    Where does Fuel convert "Persons" to "People"?
  • That is done by Inflector::pluralize().

    As it is used in applications too (for example in messages like "1 person likes this" or "2 people like this"), it aims to produce proper English.
  • Wonderful! Very useful, every day I learn something new.
  • by "so, generated migrations and models should point to 'people', not 'persons'" i mean, that generated migrations did not point to people
  • how to disable plurar function?
  • You can't, it's the convention, and the generator is coded that way.

    You could overload the oil class in your app (see the docs on how to extend classes), and change the code.

Howdy, Stranger!

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

In this Discussion