src/RocknRoot/StrayFw/Database/Postgres/Model.php
public static function fetchArray(array $conditions, array $orderBy = null, bool $critical = false)
    {
        $entity = new static();
        $selectQuery = new Select($entity->getDatabaseName(), $critical);
        $selectQuery->select($entity->getAllFieldsRealNames());
        $selectQuery->from($entity->getTableName());
        if (count($conditions) > 0) {
            $where = array();
            foreach ($conditions as $key => $value) {
                $realName = constant(get_called_class() . '::FIELD_' . strtoupper(Helper::codifyName($key)));
                $where[$realName] = ':where' . ucfirst($key);
                $selectQuery->bind('where' . ucfirst($key), $value);
            }
            $selectQuery->where($where);
        }
        if (is_array($orderBy) && count($orderBy) > 0) {
            $orders = array();
            foreach ($orderBy as $key => $value) {
                $realName = constant(get_called_class() . '::FIELD_' . strtoupper(Helper::codifyName($key)));
                $orders[$realName] = strtoupper(ucfirst($value));
            }
            $selectQuery->orderBy($orders);
        }
        $selectQuery->limit(1);
        if ($selectQuery->execute() === false) {
            return false;
        }
        $data = $selectQuery->fetch();
        if (is_array($data) === false) {
            return false;
        }

        return $data;
    }
public static function fetchArray(array $conditions, array $orderBy = null, bool $critical = false)
    {
        $entity = new static();
        $selectQuery = new Select($entity->getDatabaseName(), $critical);
        $selectQuery->select($entity->getAllFieldsRealNames());
        $selectQuery->from($entity->getTableName());
        if (count($conditions) > 0) {
            $where = array();
            foreach ($conditions as $key => $value) {
                $realName = constant(get_called_class() . '::FIELD_' . strtoupper(Helper::codifyName($key)));
                $where[$realName] = ':where' . ucfirst($key);
                $selectQuery->bind('where' . ucfirst($key), $value);
            }
            $selectQuery->where($where);
        }
        if (is_array($orderBy) && count($orderBy) > 0) {
            $orders = array();
            foreach ($orderBy as $key => $value) {
                $realName = constant(get_called_class() . '::FIELD_' . strtoupper(Helper::codifyName($key)));
                $orders[$realName] = strtoupper(ucfirst($value));
            }
            $selectQuery->orderBy($orders);
        }
        $selectQuery->limit(1);
        if ($selectQuery->execute() === false) {
            return false;
        }
        $data = $selectQuery->fetch();
        if (is_array($data) === false) {
            return false;
        }

        return $data;
    }
Fetch one row satisfying the specified conditions.

@param  array $conditions where conditions
@param  array $orderBy    order clause
@param  bool  $critical   if true, will be executed on write server
@return array|false row data