fActiveRecord->set.. / Help Please!
Hello,
I'm having troubles with the set functionality of the fActiveRecord. In our MySQL database is a table which contains a column region1 So I try to set the column:
$member->setRegion1("something"); // exception : The column specified, region_1, does not exist
But it now misses the column region_1 which is ofcourse not available because it's called region1. So how can I set the column region1 without altering the column name to region_1 in the database?
With kind regards,
Frank
-
Message #411
The method that will do this for you is fGrammar::addCamelUnderscoreRule(). You could add this method call to the configure() method for your fActiveRecord class.
protected function configure() { fGrammar::addCamelUnderscoreRule('Region1', 'region1'); }
This will have the side effect of causing any instance of Region1 becoming region1 in any code that uses fGrammar::underscorize(). I'm guessing that won't really be an issue though.
wbond09/21/09 10:19:00 -
-
Message #647
This solution should be included somewhere in the documentation around http://flourishlib.com/docs/fORM#ColumnandRecordNames. I was going nutz trying to figure this out and had to click on each thread hoping to find a solution.
gabrielu03/17/10 16:02:49 -
-
Message #678
Thanks for the note. I've added links to the fORM, OrmConventions and fActiveRecord pages about this.
wbond04/06/10 13:22:52
-
-
Message #415
Thanx, that solved the problem, but is it now a problem if another table uses the same field names? So for this database table it should become region1 instead of region_1 also.. right? Sorry if this is a beginners mistake, but it just won't seems to work.
Uncaught Exception ------------------ ..\register.php(68): Dat_geo_nl->GetRegion_1() [internal function]: fActiveRecord->__call('GetRegion_1', Array) ..\inc\flourish\fActiveRecord.php(239): fORM::getActiveRecordMethod(Object(Dat_geo_nl),'GetRegion_1') ..\inc\flourish\fORM.php(346): fORM::parseMethod('GetRegion_1') Invalid method, GetRegion_1(), calledwith kind regards,
Frank
Frank09/22/09 09:44:50 -
-
Message #416
The issue here is that you have capitalized Get. Try calling getRegion1() instead.
With the fGrammar change, getRegion1() will look for a column named region1 for any table. If you have a table with region_1 you might need to type getRegion_1(), however I don't know for sure if that will work.
wbond09/22/09 10:00:45 -
-
Message #417
Thanx this is correct,
After hours behind the computer screen i overlooked this typo. By the way this library is awesome, i'm using it for a dating site, when it's finished i will sent you the link!!
By the way is there a way to use regualar expressions in the fValidation class?
Frank
Frank09/22/09 10:18:31
-
-
-
-
Message #680
To all drivers! Hello! Come on <a href=http://vancuver.in>Auto portal today</a>.
Automobilist04/16/10 03:39:44
