jpfuentes2 / php-activerecord

ActiveRecord implementation for PHP
http://www.phpactiverecord.org/
Other
1.32k stars 443 forks source link

Null return when using has_many #66

Closed jordanvs closed 13 years ago

jordanvs commented 14 years ago

Firstly, I see some great potential in this library and I hope to be able to integrate it into some legacy php applications not using a framework.

I am trying to support a database schema of an existing application by using the convention overrides $table_name, $primary_key, etc. However, I have set up a $has_many association like this:

class RssFeed extends ActiveRecord\Model { static $table_name = 'rss_feeds'; static $primary_key = 'feedID';

static $has_many = array(
    array('rssarchives', 'class_name' => 'RssArchive', 'foreign_key' => 'feedId')
);

}

Where the RssArchive table has its convention overrides set up correctly. The RssArchive table also has a belongs_to 'RssFeed' association set up that is working fine.

The problem is that my result from calling

$feed_archives = $feed->rssarchives

is always null. I traced the php-ar code to Relationship.php line 273 where the

if (all(null,$condition_values))

line is evaluating to true and causing the return of null. Am I doing something wrong?

Thanks! Jordan

jordanvs commented 14 years ago

Also, I'm using the stable 1.0 release.

kla commented 14 years ago

Could you send the schema for your rss_feeds and rss_archive tables? I'm primarily interested in seeing the definition of the id and foreign keys.