使用Kohana ORM v3从多个表中选择数据

时间:2022-11-25 04:19:55

I can't seem to select data from multiple tables with Kohana ORM.

我似乎无法使用Kohana ORM从多个表中选择数据。

When I do:

当我做:

$obj = orm::factory('a')
         ->join('b')
         ->on('a.b_id','=','b.id')
         ->select ('b.*','a.*')
         ->find_all();

the only variables available in $obj are from table a.

$ obj中唯一可用的变量来自表a。

1 个解决方案

#1


0  

You can't overwrite table a variables with table b ones as you're instancing the Model_A, not Model_B ( ORM::factory('a') ).

当你实例化Model_A而不是Model_B(ORM :: factory('a'))时,你不能用表b覆盖表变量。

When you do this, orm will automatically append select($this->_table_name.*) after all other selects so the previous ones (their keys) will be overwritten.

执行此操作时,orm将在所有其他选择之后自动附加select($ this - > _ table_name。*),以便覆盖之前的(其键)。

#1


0  

You can't overwrite table a variables with table b ones as you're instancing the Model_A, not Model_B ( ORM::factory('a') ).

当你实例化Model_A而不是Model_B(ORM :: factory('a'))时,你不能用表b覆盖表变量。

When you do this, orm will automatically append select($this->_table_name.*) after all other selects so the previous ones (their keys) will be overwritten.

执行此操作时,orm将在所有其他选择之后自动附加select($ this - > _ table_name。*),以便覆盖之前的(其键)。