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']);
        }
    }
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']);
        }
    }
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' ] ) ; } }
Gets database results as array from a simple select query with a where clause you can provide.

@param array|string $conditions If passed as a string a database Where clause. If an array of field/value pairs will convert to a series of `field`='value' conditions joined with an AND operator.
@param array|string $options
@return array[]|null Array of records from the database result.
Gets database results as array from a simple select query with a where clause you can provide .