merge 2 object

Hello everyone

I have a function as below:

    Items.item_promo,Items.item_price,Items.item_price_tl,Items.item_currency,Items.user_type,Items.user_id,Ite ms.referer,Items.item_stock,Items.item_category,Partners.url,Partners.discount_code")
            ->join("Partners"," = Items.user_id")
            ->where(" IN (".$idsStr.")")
            ->andWhere("Items.item_stock = 1")
            ->orderBy("FIELD(, {$idsStr})")

            return $select;

I run that command two times and want to merge them into two different returns. How can I merge two object(Phalcon\Mvc\Model\Resultset\Simple) ?


You don't combine 2 objects, but you can combine 2 arrays. In theory, if the object does not have methods, you could do something like

$obj = (object) array_merge((array) $objA, (array) $objB);

But in this case, the object has methods. So what you can do would be

$objA = $resultA->toArray();
$objB = $resultB->toArray();

$output = array_merge($objA, $objB);

Maybe someone else has other ideas.

```php $output = array_merge($objA, $objB); ```

You may be able to convert them back into a Resultset through one of the cloneResultMap, cloneResultMapHydrate or cloneResult methods :