I use Propel 2. I moisten objects through relationships, for example:
$return = OrderQuery::create() ->joinWith('Customer') ->joinWith('Status') ->find() ->toArray(TableMap::TYPE_PHPNAME, true, [], true);
The resulting array will look something like this:
{ "Id": 1, "CustomerId": 1, "StatusId": 1, "Initiated": "2016-01-01T01:01:01+00:00", "Customer": { "Id": 1, "Forname": "Test", "Surname": "Smith", "Orders": [ "*RECURSION*" ] } "Status": { "Id": 1, "Title": "title 1", "Priority": 1, "Orders": [ "*RECURSION*" ] }, }
I want to delete fields where the value is *RECURSION* . I tried using the $alreadyDumpedObjects (3) parameter for toArray() , but that didn't seem to help. I could also do some kind of array form coming with unset() calls, but I hope there is a better way, maybe with formatting or something else?
For bonus points, I would really like to remove the columns that define the foreign key relationship. For example, CustomerId will go, but Customer will remain.
php propel propel2
LeonardChallis
source share