0

In a PropelORM object retrieved from a query with virtual columns from a join, is there a way/method to include virtual columns in the toArray() call?

For example:

$book = BookQuery::create()
  ->join('Book.Author')
  ->with('Author')
  ->where('Author.Name = ?', 'Jane Austen')
  ->findOne();

$aBook = $book->toArray();

In the above code, I would like the array generated in the toArray() call to have the fields from the Authors table as well, not just the Books table.

Will Bonde
  • 560
  • 6
  • 19

1 Answers1

2

If you look at the toArray() method definition, you'll see that it accepts a $includeForeignObjects parameter. I think it's more or less what you are looking for.

$book = BookQuery::create()
  ->join('Book.Author')
  ->with('Author')
  ->where('Author.Name = ?', 'Jane Austen')
  ->findOne();

$aBook = $book->toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = true);

The arguments list isn't pretty, but it should work.

K-Phoen
  • 1,260
  • 9
  • 18