(1-1/1)
Hi Fox Racing,
This took me a while to find but you can achieve this by using the 'foreign_key' option.
E.g:
static $has_many = array(
array('offerentities', 'foreign_key' => 'offer_id')
);
I hope this helps.
Elan
(1-1/1)
June 27 2010
May 8, 2013
Subject: Relationships, change id column name
Hi, I would like to know if it's possible to tell the $has_many what name to use as an ID. Now the code looks for offerentity_id but it's called offer_id in the db and I have to follow a convention for file naming.
Can someone please help!
Thanks!
Fatal error: Uncaught exception 'ActiveRecord\DatabaseException' with message '42S22, 1054, Unknown column 'offerentity_id' in 'where clause'' in C:\Program Files\EasyPHP-12.1\www\aecq\classes\libs\php-activerecord\lib\Connection.php:276 Stack trace: #0 C:\Program Files\EasyPHP-12.1\www\aecq\classes\libs\php-activerecord\lib\Table.php(208): ActiveRecord\Connection->query('SELECT `regions...', Array) #1 C:\Program Files\EasyPHP-12.1\www\aecq\classes\libs\php-activerecord\lib\Table.php(199): ActiveRecord\Table->find_by_sql('SELECT `regions...', Array, false, NULL) #2 C:\Program Files\EasyPHP-12.1\www\aecq\classes\libs\php-activerecord\lib\Model.php(1428): ActiveRecord\Table->find(Array) #3 C:\Program Files\EasyPHP-12.1\www\aecq\classes\libs\php-activerecord\lib\Relationship.php(491): ActiveRecord\Model::find('all', Array) #4 C:\Program Files\EasyPHP-12.1\www\aecq\classes\libs\php-activerecord\lib\Model.php(493): ActiveRecord\HasMany->load(Object(OfferEntity)) #5 C:\Program Files\EasyPHP-12.1\www\aecq\classes\libs\php-active in C:\Program Files\EasyPHP-12.1\www\aecq\classes\libs\php-activerecord\lib\Connection.php on line 276