Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

fORM::mapClassToTable when table name is singular

posted by ben 9 years ago

i'm trying to map a class to a table with a singular name. the conventional way for this to work is to pluralize the table name but this will not work in my case since i'm trying to access an existing database used by other applications.

it gives me this error: The noun specified could not be singularized

anyone knows any work-around for this?

Can you post some code, including the fActiveRecord class, your database table name and the method call that caused the error?

posted by wbond 9 years ago

Hi wbond,

Sorry for late reply. Here are some info:

fActiveRecord class:

class UserCharacter extends fActiveRecord{

}

database table name: user_character

error caused by:

$user_character= new UserCharacter();
echo $user_character->reflect();

error message:

Uncaught fProgrammerException
-----------------------------
{doc_root}\\test\\index.php(22): fActiveRecord->reflect()
{doc_root}\\include\\lib\\flourish\\fActiveRecord.php(2343): fORMRelated::reflect('UserCharacter', Array, false)
{doc_root}\\include\\lib\\flourish\\fORMRelated.php(1035): fORM::classize('MSSNGR_CHAR_LIS...')
{doc_root}\\include\\lib\\flourish\\fORM.php(337): fGrammar::singularize('MSSNGR_CHAR_LIS...')
{doc_root}\\dinclude\\lib\\flourish\\fGrammar.php(572)
The noun specified could not be singularized

i tried the other tables with singular database table names and it seems that they are working just fine. one specific thing that i have noticed here is the accessing of MSSNGR_CHAR_LIST table which have caused the problem. is there any way to disable it from accessing unnecessary database tables?

thanks for your help

posted by ben 9 years ago

Flourish explores your database and finds related tables and makes them available via simple method calls. In this case it found a related table, but the related table wasn't plural. You'll probably need to map all of your tables to classes. There isn't really a way around this that I can think of.

fORM::mapClassToTable('MssngrCharList', 'mssngr_char_list');
// Add other singular tables too
posted by wbond 9 years ago