我试图去处理Kohana ORM,但我有点卡住了。 我已创建类别和发布模型,并根据category_id建立关系。Kohana ORM关系
我可以分别获取帖子和类别模型,但我似乎无法使用关系获取它们。例如:
// Get first category
$category = ORM::factory('category', 1);
foreach ($category->posts as $post)
{
echo $post->title;
}
以上只是给了我一个空白屏幕(我知道我不应该在输出控制器任何东西,只是想获得它的工作第一)。
print_r($category);
给我此:
Model_Category对象([_has_many:保护] =>数组([帖] =>数组([模型] =>讯息[foreign_key] => CATEGORY_ID [通过] =数组()[__保存] =>数组()[_validate:保护] => [_rules:protected ] ArrayList()[_callbacks:protected] => Array()[_filters:protected] => Array()[_labels:protected] => Array()[_object:protected] => Array([id] => 1 [title] => [description] =>)[_changed:protected] => Array()[_related:protected] => Array()[_loaded:protected] => [_saved:protected] => 1 [_sorting: protected] => Array([id] => ASC)[_foreign_key_suffix:protected] => _id [_object_name:protected] => category [_object_plural:protected] => categories [_table_name:protected] => categories [_table_columns:protected] => Array([id] =>数组([type] => int [min] => 0 [max] => 65535 [column_name] => id [column_default] => [data_type] => smallint unsigned [is_nullable] => [ordinal_position] =>显示] => 6 [comment] => [extra] => auto_increment [key] => PRI [privileges] =>选择,插入,更新,引用)[title] => Array([type] => string [character_maximum_length ] => 65535 [column_name] => title [column_default] => [data_type] => text [is_nullable] => [ordinal_position] => 2 [collation_name] => latin1_swedish_ci [comment] => [extra] => [key ] => [privileges] => select,insert,update,references)[description] => Array [character] > text [is_nullable] => [ordinal_position] => 3 [collation_name] => latin1 _swedish_ci [comment] => [extra] => [key] => [privileges] =>选择,插入,更新,引用))[_ignored_columns:protected] => Array()[_updated_column:protected] => [_created_column: Database_MySQL Object([_connection_id:protected] => [_primary_key:protected] => id [_primary_val:protected] => name [_table_names_plural:protected] => 1 [_reload_on_wakeup:protected] => ] => d6ad44aa068ae69071b9614f2a4a760bf55d9307 [_identifier:protected] =>[last_query] => SHOW FULL COLUMNS FROM
categories [[_instance:protected] => default [_connection:protected] =>资源ID#36 [_config:protected] => Array([type] => mysql [connection ] =>数组([hostname] => localhost [database] => cms_test_kohana [persistent] =>)[table_prefix] => [charset] => utf8 [caching] => [profiling] => 1))[_db_applied: Array()[_db_pending:protected] => Array()[_db_reset:protected] => 1 [_db_builder:protected] => [_with_applied:protected] => Array()[_preload_data:protected] => Array())
任何人都可以帮忙吗?
任何意见赞赏。
谢谢。
显示您的机型配置 – biakaveron 2011-01-10 16:30:23