MVC Cake PHP Active Record userprofile array userprofileUser









![Модели: Active Record • Сохранение данных • Выборка данных $user_profile = array(); $user_profile['User. Profile']['user_id'] Модели: Active Record • Сохранение данных • Выборка данных $user_profile = array(); $user_profile['User. Profile']['user_id']](https://slidetodoc.com/presentation_image_h/341fb686fb3bdd5bbd7968a8315ad341/image-10.jpg)
















- Slides: 26
Модель MVC в Cake. PHP
Модели: Active Record • Сохранение данных • Выборка данных $user_profile = array(); $user_profile['User. Profile']['user_id'] = $user_id; $user_profile['User. Profile']['paypalemail'] = $data['User']['paypalemail']; $user_profile['User. Profile']['paypalaccount'] = $data['User']['paypalaccount']; $result = $this->User. Profile->save($user_profile); $options = array( 'conditions' => array( 'Featured. Artist. type & 128 > 1', 'YEAR(Featured. Artist. created)' => $year, ), 'order' => array('Featured. Artist. created DESC'), 'fields‘ => array('Featured. Artist. type’, ‘'Featured. Artist. id’, 'Featured. Artist. created’) ); $best_artists = $this->Featured. Artist->find('all', $options );
Модели: Валидация 1. alpha. Numeric 2. between 3. blank 4. cc 5. comparison 6. custom 7. date 8. decimal 9. email 10. equal. To 11. file 12. ip 1. max. Length 2. min. Length 3. money 4. multiple 5. number 6. numeric 7. phone 8. postal 9. ssn 10. url 11. user. Defined
Модели: Валидация <? php 1. class User extends App. Model { 2. var $name = 'User'; var $validate = array( 'password' => array( 1. 'length. Password' => array( 2. 'rule' =>array('mb_between', 'password', 6, 32 3. 'message'=>'Password too short', 4. 'last' => true, //USE FOR REGISTRATION 5. //'on' => 'create', -- DON'T UNCOMMENT THIS !! 6. ), 7. 'same. Password' => array( 8. 'rule' => array('check. Same. Password') , 9. 'message' => 'Passwords not matched', 10. ), 11. ), ); 1. ); 2. ? >
Модели: Валидация /** 1. * Validation method used by model for 2. * a custom validation 3. * @param array $data 4. * @return boolean 5. */ 6. public function check. Same. Password($data) { 7. if ($this->data['User']['password'] 1. == 2. $this->data['User']['password 1']) 1. { 8. return true; 9. } 10. else{ 11. return false; 12. } 13.
Модели: Связи Relationship Association Type one to one has. One one to many has. Many many to one belongs. To many to many has. And. Belongs. To. Many
Стандартные хелперы 1. Ajax 2. Cache 3. Form 4. Html 5. Javascript 6. Number 1. Paginator 2. Rss 3. Session 4. Text 5. Time 6. Xml
Поддержка Ajax • На основе Prototype JS Library • Создание обычной ссылки: • • $html->link( • ); __(‘Add Post’, true), array('controller' => 'posts', 'action' => 'add') • • Создание Ajax ссылки: 1. $ajax->link(‘Add Post’, 2. 3. 6. ); ‘/posts/add’, array( ‘update’ => ‘add. Post. Div’, ‘complete’ => ‘Effect. Slide. Down(“add. Post. Div”)’ )
Маршрутизация (Routing) • Механизм сопоставления УРЛов и методов контроллеров • Router: : connect('/', array('controller' => 'pages', 'action' => 'home')); • Router: : connect('/login', array('controller' => 'users', 'action' => 'login')); • Router: : connect('/register', array('controller' => 'users', 'action' => 'register')); • Router: : parse. Extensions(‘xml’, ‘rss’);