cakephp column mapping -


i have started working cakephp, complete newbie working in framework , have taken on legacy system pretty awful database structure. went in , added primary keys tables didn't have them. however, can't find information on map columns in model, , use links can oriented in area. i'm starting user table, has been named "system". created model called user:

class user extends appmodel {     var $name = 'user';      var $usetable = 'system';        } 

i want map columns property names more in line conventions without changing existing database, since using table. table structure is:

table: system  field name     datatype     nullable   default ------------------------------------------------------------------ user_id        tinyint(4)   no         none auto_increment s_rec_type     tinyint(4)   yes        null s_user_id      varchar(20)  yes        null s_init         char(2)      yes        null  s_password     varchar(12)  yes        null admin_access   tinyint(4)   no         0 fname          varchar(50)  no lname          varchar(50)  no email_address  varchar(50)  yes        null created        datetime     yes        null modified       datetime     yes        null  // added email_address, created, , modified. 

i want map columns in model follows:

user_id       -> id s_rec_type    -> usertype s_user_id     -> username s_init        -> initials s_password    -> password admin_access  -> adminaccess fname         -> firstname lname         -> lastname email_address -> emailaddress created       -> created modified      -> modified 

so can use methods $this->user->findallbyid($id) or $this->user->findbyinitials('sb') or access id $this->user->id instead of $this->user->user_id , more consistent naming conventions code easier understand.

this table used determine menu options users have access , pages user can access. i'll deal later.

i take @ virtual fields. model attribute initialization might this:

var virtualfields = array (     'usertype' => 's_rec_type',     'username' => 's_user_id',     'initials' => 's_init',     .....     'modified' => 'modified' ); 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -