Copy 'where' condition to another query

Hi,

I am trying to copy the where condition from a query to another query.

// Get the where
$whereClause = $query->clause('where');

// Doesn't work
$anotherQuery->where(function (QueryExpression $exp) use ($whereClause) {
  return $whereClause;
});

How do I insert it into a another query ?

1 Like

A simple

$whereClause = $query->clause('where');
$otherQuery->where($whereClause);

should suffice