/** * {@inheritDoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $result = $this->connection->executeQuery('MATCH n RETURN COUNT(n) as count'); $nodeCount = $result[0][0]; if ($nodeCount === 0) { try { $this->loadData(); } catch (\Exception $e) { $output->writeln(sprintf('An error occurred: %s', $e->getMessage())); } $output->writeln('Initialized'); } else { $output->writeln('Already initialized'); } }
/** * Execute Cypher query and return result * * @param string $query * * @return \Everyman\Neo4j\Query\ResultSet */ protected function getResult($query) { return $this->connection->executeQuery($query); }