public static function getAllRecordsByWhere($conditions = [], $options = [])
    {
        $className = get_called_class();

        $options = Util::prepareOptions($options, [
            'indexField' => false,
            'order' => false,
            'limit' => false,
            'offset' => 0,
            'calcFoundRows' => !empty($options['limit']),
            'extraColumns' => false,
            'having' => false,
        ]);

        // initialize conditions
        if ($conditions) {
            if (is_string($conditions)) {
                $conditions = [$conditions];
            }

            $conditions = static::_mapConditions($conditions);
        }

        // build query
        $query  = 'SELECT %1$s `%3$s`.*';
        $query .= static::buildExtraColumns($options['extraColumns']);
        $query .= ' FROM `%2$s` AS `%3$s`';
        $query .= ' WHERE (%4$s)';

        $query .= static::buildHaving($options['having']);

        $params = [
            $options['calcFoundRows'] ? 'SQL_CALC_FOUND_ROWS' : '',
            static::$tableName,
            $className::$rootClass,
            $conditions ? join(') AND (', $conditions) : '1',
        ];

        if ($options['order']) {
            $query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order']));
        }

        if ($options['limit']) {
            $query .= sprintf(' LIMIT %u,%u', $options['offset'], $options['limit']);
        }

        if ($options['indexField']) {
            return DB::table(static::_cn($options['indexField']), $query, $params, null, [static::class,'handleError']);
        } else {
            return DB::allRecords($query, $params, [static::class,'handleError']);
        }
    }