How call method of Model from another Module / Как использовать модель другого модуля?

Hi, I have models/Users.php in Module - auth. I want to call method new Users -> getUser() in Module - profile

How can I do?


/modules/auth/models/Users.php ``` public function getUser($username) { $user = Users::findFirst("id = '44'"); return $user; } ``` /modules/profile/Module.php

            'Auth\Models' => __DIR__ . '/../auth/models/'


$profile = new \Auth\Models\Users();
//This return all fields, but it with value = null

But, if i write in modules/profile/indexController:

Users::findFirst("id = '44'"));
//Return all fields with correct data

Help me please :) I want to call model from another Module.

Sorry for my English :)

How can I use PHQL in Models?

What I do is very simple. Just register new namespace for models you need use inside your module:

    __NAMESPACE__ . '\\Controllers' => __DIR__ . '/controllers/',
    __NAMESPACE__ . '\\Models' => __DIR__ . '/models/',
    'App\Users\Models' => dirname(__DIR__) . '/users/models/'

But do you have really strong reason do that? Cant you just use relation between models?

edited Sep '14

Thanks, it is work, use ``` Users::getUser($username); ``` No, i am not use relation. I have two modules working with one a database table.

$profile = new \Auth\Models\Users();
**//This return all fields, but it with value = null**

I think that this is bug, because:


working! But maybe I'm wrong.

Well tell you truth Im not sure what are you doing or whats inside of your models. Especially you didnt describe your function getUser (because you said you dont use relation between models) so perhaps problem is inside your function. How do you get user by username? Something like:

    'conditions' => 'username = ?1',
    'bind' => array(1 => $username)