Find one entity or return null.

@param array|null $query

@return EntityInterface|null
428808
public function findOne(array $query = null)
    {
        $data = (clone $this)->where($query)->fetchData();

        if (empty($data[0])) {
            return null;
        }

        return $this->orm->make($this->class, $data[0], ORMInterface::STATE_LOADED, true);
    }
502401
public function query($query)
    {
        // If the query is empty, we'll return false
        if ($query === null || empty($query)) {
            return false;
        }

        if ($this->read) {
            // If read is true, we'll perform a read search, retrieving one record
            $results = $this->connection->read($this->getDn(), $query, $this->getSelects());
        } elseif ($this->recursive) {
            // If recursive is true, we'll perform a recursive search
            $results = $this->connection->search($this->getDn(), $query, $this->getSelects());
        } else {
            // Read and recursive is false, we'll return a listing
            $results = $this->connection->listing($this->getDn(), $query, $this->getSelects());
        }

        if ($results) {
            return $this->processResults($results);
        }

        return false;
    }
425137
public function allArray(Query $query = null) {
		$iterator = $this->getIterator();
		$array = $iterator->all($query);
		$array = $this->forgeEntity($array);
		return $array;
	}
36890
protected function checkQuery($query=null)
    {
        if ($query) {
            $this->getQuery()->set($query);
            unset($query);
        }
        
        $query = $this->getQuery();
        
        // if no table then set table
        if (!isset($query['table'])) {
            $query['table'] = $this->getTableName();
        }
        
        // use model database.table_prefix
        if (!isset($query['database']) && isset($this['database'])) {
            $query['database'] = $this['database'];
        }
        
        if (!isset($query['table_prefix']) && isset($this['table_prefix'])) {
            $query['table_prefix'] = $this['table_prefix'];
        }
        
        return static::formatQuery($query);
    }
1251258
public function fetch($query)
    {
        $key = $this->_resolveKey($query);
        $storage = $this->_resolveCacher();
        $result = $storage->read($key);
        if (empty($result)) {
            return null;
        }

        return $result;
    }
705270
public function search($query)
    {
        $classes = $this->getClassMetadata();
        return $this->_sm->getUnitOfWork()->loadCollection($classes, $query);
    }
922896
public function findOneBy(array $criteria)
    {
        $result = current($this->findBy($criteria, null, 1));

        return $result ? : null;
    }
16965
public function findOne($query, array $data = null) {       
        $stmt = $this->executeQuery($query, $data);   
        
        return $stmt->fetch(\PDO::FETCH_ASSOC);
    }
697682
protected function guessQuery(array $query): Query
    {
        $server = $query['server'] ?? $this->getServer();
        $sql = $query['query'];
        $bindings = $query['bindings'] ?? [];
        $tables = $query['files'] ?? [];
        $settings = $query['settings'] ?? [];
        
        return $this->createQuery($server, $sql, $bindings, $tables, $settings);
    }
672870
public function setQuery($query = null)
    {
        $this->query = [];
        return ($query === null)
            ? $this
            : $this->addQueryData($query);
    }
50969
public function findAll(array $query = [])
    {
        $data = $this->client->get(Inflector::pluralize($this->getResourceName()), $query);

        return $this->createMany(reset($data));
    }
1012809
public function query($query, $data = null){

        try {

            if(!$data){
                return parent::query($query);
            }//if

            $stmt = parent::prepare($query);

            if(!is_array($data)){
                $data = Array($data);
            }//if

            $stmt->execute($data);

            return $stmt;

        } catch(\PDOException $e){
            TRIGGER_ERROR("DB:: Query Error | {$query}\n".$e->getMessage() . "\n" . $e->getTraceAsString(),E_USER_WARNING);
            throw new \Disco\exceptions\DBQuery($e->getMessage(), (int)$e->getCode());
        }//catch

    }
97618
public function query($query, $type = '')
    {
        try {
            if ($type === 'SELECT') {
                return $this->conn->query($query);
            }

            return $this->conn->exec($query);
        } catch (\PDOException $e) {
            $this->error = $e->getMessage();

            return null;
        }
    }
885252
protected function setJoin($query = null)
    {
        $query = $query ?: $this->query;

        $baseTable = $this->related->getTable();

        $key = $baseTable.'.'.$this->related->getKeyName();

        $query->join($this->table, $key, '=', $this->getOtherKey());

        return $this;
    }
580378
public function query($query) {
    $dataConnection = $this->app->getDataConnection($this->connection);
    $foundObjects = $dataConnection->query($this->table, $query);
    $foundModels = array();
    foreach ($foundObjects as $foundObject) {
      /**
       * @var $model \MABI\Model
       */
      $model = call_user_func($this->modelClass . '::init', $this->app);
      $model->load($foundObject);
      $foundModels[] = $model;
    }
    return $foundModels;
  }
1082077
public static function find(array $query)
    {
        $pubs = Client::get('publication', $query);
        return array_map(function ($data) { return new self($data); }, $pubs);
    }
678039
public function findOneBy(array $criteria)
    {
        $query = $this->createQueryBuilder($criteria);
        if (!($object = $this->getOneOrNullResultFromQueryBuilder($query))) {
            $this->throwException('The resource was not found', 'not-found');
        }
        return $object;
    }