I have two tables named utilities and types that i am trying to access the other fields within types from the utilities view. e.g; $utilities->type->type;
Utilities would have_one type
and type would belong_to utility right?
This is how i have it currently, and rather than referencing utilities.type_id its setting the key as utilities.id. As a result its pulling different types for each row, even though they are all of the same type.

How should i lay my models relationships out using Kohana 3.2 ORM.
Utilities
<?php
class Model_Utility extends ORM {
protected $_has_one = array(
'type' => array(
'model' => 'type',
'foreign_key' => 'type_id',
),
);
Table Structure
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| utility_name | varchar(255) | NO | | NULL | |
| type_id | int(11) | NO | | NULL | |
| contact_name | varchar(255) | NO | | NULL | |
| contact_email | varchar(255) | NO | | NULL | |
| contact_phone | varchar(255) | NO | | NULL | |
+---------------+--------------+------+-----+---------+----------------+
Types
class Model_Type extends ORM {
protected $_belongs_to = array(
'utility' => array(
)
);
Table Structure
+---------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+----------------+
| type_id | int(11) | NO | PRI | NULL | auto_increment |
| type | varchar(255) | NO | | NULL | |
+---------+--------------+------+-----+---------+----------------+
Utility
belongs_toType (utilitieshas atype_idkey), and Typehas_manyutilities.PS. Also you need to define a PK name for
typestable ($_primary_keyproperty).