Question: Access Second Relationship Cactiverecord With()

I have not been able to chase down a clear answer to this yet. I have not done much work with relationships with any more than 2 tables with Yii so this is not something I have had to deal with yet.

I have 3 tables:

product -> product_data <- product_data_source

product HAS_MANY product_data

product_data_source HAS_MANY product_data

There is a many-to-one relationship here so I know that I will need to handle the results as an array. I want to return data from both tables for product_id 99:

$product = Product::model()->with('productData', 'productData.productDataSource') -> findByPk(99);

$productData = $product -> productData; // This will get me the result from the product_data_table

$productDataSource = $product -> productDataSource;  // Does not work

I would then handle $product_data using a foreach.

However, this produces the error:

Property "McgProduct.productDataSource" is not defined.

How do I reference the result from the product_data_source table? The following is clearly wrong:

$productDataSource = $product -> productDataSource; 

Alright, looks like I clarified my own problem - nothing like laying it out objectively in print.

$productDataSource =  $productData[0]->productDataSource;

The above would reference the row on the second table. I could then access a field on that table using:

echo $productDataSource->product_data_source_name;