fetchAll() public method

Fetch Entities (optionally based on a GQL query)
public fetchAll ( $str_query = null, array | null $arr_params = null ) : Entity[]
$str_query
$arr_params array | null
return Entity[]
Ejemplo n.º 1
0
 /**
  * @param string|\Atrauzzi\PhpEventSourcing\AggregateRoot $aggregateType
  * @param int|string $aggregateId
  * @return \Atrauzzi\PhpEventSourcing\AggregateRoot
  */
 public function find($aggregateType, $aggregateId)
 {
     $gdsEvents = $this->eventStore->fetchAll('SELECT * FROM Event WHERE aggregate_type = @aggregateType AND aggregate_id = @aggregateId ORDER BY sequence ASC', [$aggregateType::getType(), $aggregateId]);
     /** @var \Atrauzzi\PhpEventSourcing\AggregateRoot $aggregateRoot */
     $aggregateRoot = new $aggregateType();
     $aggregateRoot->absorb($this->hydrateEvents($gdsEvents));
     return $aggregateRoot;
 }
 /**
  * Run the query as a "select" statement against the connection.
  *
  * @return array
  */
 protected function runSelect()
 {
     //Convert query to GQL string.
     $query = $this->toGql();
     //Get the bindings
     $bindings = $this->getBindings();
     //Create the GS Store.
     $store = new Store($this->from, $this->connection->getGoogleGateway());
     $runQuery = $store->fetchAll($query, $bindings);
     dd($runQuery);
 }