zitter
(Zitter)
February 26, 2010, 9:40pm
1
Hi, I would like to know if there is a way to organize models inside subdirs in "model" dir. I mean a structure like this:
model/group1/model1.php
model/group1/model2.php
model/group1/model3.php
model/group2/model4.php
model/group2/model5.php
model/group3/model6.php
and so on…
if it is, how to call model inside a subdir?
Thanks for all
Danilo
jayrulez
(Waprave)
February 26, 2010, 11:08pm
2
Hi, I would like to know if there is a way to organize models inside subdirs in "model" dir. I mean a structure like this:
model/group1/model1.php
model/group1/model2.php
model/group1/model3.php
model/group2/model4.php
model/group2/model5.php
model/group3/model6.php
and so on…
if it is, how to call model inside a subdir?
Thanks for all
Danilo
add your directory alias to the import array in conig.
zitter
(Zitter)
February 27, 2010, 7:45am
3
but alias works with one directory, or not?
I mean I need to put models inside several directories (models/group1 models/group2 and so on…), not all in one.
andy_s
(Arekandrei)
February 27, 2010, 12:53pm
4
zitter:
but alias works with one directory, or not?
I mean I need to put models inside several directories (models/group1 models/group2 and so on…), not all in one.
You should add all subdirectories. But I don’t think you need all of them at once. If your controlller use group1 and group5 models, then better use Yii::import(‘protected.models.group1’) [and group5] in it’s init method.
zitter
(Zitter)
February 28, 2010, 12:06am
5
Thanks andy_s it works perfectly
Hey Guys, I’m having problems getting this to work. I have the following in my controller:
class UsersTestHarnessController extends Controller
{
public function init()
{
Yii::import("protected.models.Users");
}
...
When my controller action is called I get:
Alias "protected.models.Users" is invalid. Make sure it points to an existing directory or file.
I have tried upper/lower case, adding an asterisk…
mikl
(Mike)
August 20, 2010, 1:18pm
7
Alias "protected.models.Users" is invalid. Make sure it points to an existing directory or file.
I have tried upper/lower case, adding an asterisk…
Replace protected with application.
I replaced my import with:
Yii::import("application.models.Users.*");
It works! Thank you very much Mike!