Http 500 error when using AR relations

Hi all,

I'm new to the framework, and i am quite impressed with it. Only now i have a problem. When i use the ActiveRecord relations i get a Http 500 error.

What i have is as follows. I have a Blog model and a Comment model. I want to get the comments that belong to the blogs. In my blog model i specified the relation like this:



public function relations()


{


	return array(


		'comments'=>array(self::HAS_MANY, 'Comment', 'blog_id')


	);


}


I then try to find all blogs, which works fine. Then i try to get the comments that belong to the blogs:



$blogs = Blog::model()->with('comments')->findAll();


Then i just get a Http 500 error and in my error log this is inserted:



[Wed Dec 17 11:22:45 2008] [error] [client 62.51.191.128] PHP Fatal error:  Exception thrown without a stack frame in Unknown on line 0


Could anyone please help? I love the framework but this is just weird. By the way, i'm running a windows install of Apache & PHP 5.3 & MySQL. It couldnt be the PHP5.3 alpha could it? I've never seen it break anything OO based.

Thanks in advanced!

EDIT

I seem to have found the problem, somewhere along the line this exception is thrown: The relation "comments" in active record class "Blog" is specified with an invalid foreign key "blog". The foreign key does not point to either joining table.

The problem why it gives a HTTP 500 error is because for some reason PHP refuses to throw an exception from a controller. The reason for the error is because the framework doesn't load foreign keys for some reason.

Do you actually define a Foreign Key in your database table? Unlike other frameworks I've tried, this one requires an actual Foreign Key to be defined (which is kind of annoying to me, but I'm adapting). Once I did so, I stopped getting the "The foreign key does not point to either joining table." error.

Quote

Unlike other frameworks I've tried, this one requires an actual Foreign Key to be defined

Take a look at the info box near thetop of: http://www.yiiframew…de/database.arr

Yii will then identify the relationships in your db schema but of course you still won't have the AR functionality in the database (on delete, on update events won't trigger any actions).

Quote

Do you actually define a Foreign Key in your database table? Unlike other frameworks I've tried, this one requires an actual Foreign Key to be defined (which is kind of annoying to me, but I'm adapting). Once I did so, I stopped getting the "The foreign key does not point to either joining table." error.

Wow, how stupid >.< That worked. I did try that before, but because my SQL manager requires me to compile/commit the table after altering it i thought it didn't work. Stupid on my part so thank you so much! Now i can finally use this framework to its full potential!