The undefined property-error comes probably from your ID
. phpactiverecord
assumes, nay FORCES all properties to be lowercase.
This means that all the fields should be called lowercase. E.G., your keys should be inspectorid
and contactid
.
Not that this is the case for columns only. Class names (php classes) should obviously be the case they actually are, and so should table names.
I always explicitly define ALL elements of a connection to avoid that assumption problem. This means both connection will have all elements for me:
static $belongs_to = array(
array('somename',
'foreign_key'=>'someid',
'primary_key'=>'id',
'class_name'=>'Models\\NameSpace\\YourModelClassName')
);
but also the same fields are needed for the has_many
. The primary in the belongs_to
is the id of the OTHER table, and the foreign key is the key in this table (and when I say key, I mean the column name). For the belongs to the foreign key is the key in the other table, and the primary key the key in this table.
Also, mind the double slashes for the namespace.