protected function query($query, $where = null, $size = null, $offset = null)
    {
        $params = [];

        if (is_array($where)) {
            $conditions = [];
            foreach($where as $column => $value) {
                $placeholder = '?';
                $value = '' . $value;

                $conditions[] = $column . ' = ' . $placeholder;
                $params[] = $value;
            }
            if (count($conditions)) {
                $query .= ' WHERE ' . implode(' AND ', $conditions);
            }
        }

        if (!is_null($size)) {
            $query = $this->getPersistence()->getPlatForm()->limitStatement($query, $size, $offset);
        }

        return $this->getPersistence()->query($query, $params);
    }