Cakephp 3 : Without use joining is it possible load another model in a model? -


in controller can use loadmodel method table data in cakephp.but possible in model? example have used orm/table class. defined table name used table method.like below code

$this->table('blogs'); 

is possible declare table in same way without association ?

note : able in controller.

if want load model in table can use tableregistry reference

use cake\orm\tableregistry $othertable = tableregistry::get('other'); //do other table //example $somerecord = $othertable->find()->first(); 

if model associated other model want load via association (belongsto, hasone etc.) can directly use example:

$this->othermodel->find()->contain()->where(['somecondition' => 'value'])->first() 

having said that, cannot define 2 tables 1 if trying do. can load , use different table inside table, can't define 2 tables under 1 table class.

i don't understand why don't want define association here sounds should do, hope table registry option covers you


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -