Column display

I just started working with CakePHP, so I'm a complete beginner working in this environment and took over an outdated system with a rather awful database structure. I went in and added primary keys to tables that didn't have them. However, I cannot find information on where to match columns in the model, and can use some links so that I can navigate in this area. I start with my user table, which has been called the "system." I created a model called User:

class User extends AppModel {
    var $name = 'User'; 
    var $useTable = 'system';       
}

I want to map columns to property names that are more consistent with conventions without modifying the existing database, as they currently use this table. Table structure:

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

// I added email_address, created, and modified.

I want to map the columns in the model as 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

, $this- > User- > findAllById ($ id) $this- > User- > findByInitials ('sb'), id $this- > User- > id , - $this- > User- > user_id, , .

, . .

+3
2

. :

var virtualFields = array (
    'UserType' => 's_rec_type',
    'UserName' => 's_user_id',
    'Initials' => 's_init',
    .....
    'Modified' => 'modified'
);
+3

Source: https://habr.com/ru/post/1787722/


All Articles