php - CakePHP Auth retrieve extra data -


i learning cakephp, excuse me

i using cakephp 1.2.5 auth component userscontroller. user model contains 2 tables:

class user extends appmodel {     var $name = 'user';     var $belongsto = 'company'; } 

when login() called, see data being retrieved in sql log (left join being executed), model seems correct, auth stores data users table , drops else. how can retrieve company data later on without doing query?

or if you're not comfortable modifying core library me, do...

on userscontroller.login action

function login() {     if ($this->auth->user()) {         $session->write('company', $this->user->company->findbyid($this->auth->user('id')));         $this->redirect($this->auth->redirect());     }  } 

you can access company details using $this->session->read('company.name') on controller , $session->read('company.name') on views. don't forget add session component , helper.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -