static public function formatQueryOptions($options=null)
    {
        if (!isset($options)) {
            return [];
        }
        
        if (is_scalar($options)) {
            $options = ['where' => [$options]];
        } elseif (isset($options['where'])) {
            $options['where'] = (array) $options['where'];
        } else {
            $isWhere = true;
            foreach ($options as $k => $v) {
                if (is_numeric($k)) {
                    unset($options[$k]);
                    $options['where'][] = $v;
                } elseif (in_array($k, ['distinct', 'fields', 'from', 'table', 'order', 'pagesize', 'page', 'result_key'])) {
                    $isWhere = false;
                    break;
                }
            }
            if ($isWhere) {
                $options = ['where' => $options];
            } else {
                $options['where'] = [];
            }
        }
        
        return $options;
    }