Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the difference between model->alias and model->name in CakePHP?

Tags:

php

cakephp

alias and name are both properties in cake models. They seem to be similar, but since both of them exist, there must be a difference. What is it?

like image 395
allyourcode Avatar asked Jul 30 '09 03:07

allyourcode


1 Answers

I'm guessing, but an alias could be the assigned value when you have a relationship between a model and another and you give the associated model a name not equal to that of the class.

For example:

$hasMany = array('UserNew' => array('className' => 'User'));

In that case, you're using the model that's actually called User, but you're referencing it as 'UserNew'.

like image 146
MSR Avatar answered Oct 03 '22 03:10

MSR