public static function getRecordByWhere($conditions, $options = [])
    {
        if (!is_array($conditions)) {
            $conditions = [$conditions];
        }

        $options = Util::prepareOptions($options, [
            'order' => false,
        ]);

        // initialize conditions and order
        $conditions = static::_mapConditions($conditions);
        $order = $options['order'] ? static::_mapFieldOrder($options['order']) : [];

        return DB::oneRecord(
            'SELECT * FROM `%s` WHERE (%s) %s LIMIT 1',

            [
                static::$tableName,
                join(') AND (', $conditions),
                $order ? 'ORDER BY '.join(',', $order) : '',
            ],

            [static::class,'handleError']
        );
    }
public static function getRecordByWhere($conditions, $options = [])
    {
        if (!is_array($conditions)) {
            $conditions = [$conditions];
        }

        $options = Util::prepareOptions($options, [
            'order' => false,
        ]);

        // initialize conditions and order
        $conditions = static::_mapConditions($conditions);
        $order = $options['order'] ? static::_mapFieldOrder($options['order']) : [];

        return DB::oneRecord(
            'SELECT * FROM `%s` WHERE (%s) %s LIMIT 1',

            [
                static::$tableName,
                join(') AND (', $conditions),
                $order ? 'ORDER BY '.join(',', $order) : '',
            ],

            [static::class,'handleError']
        );
    }
public static function getRecordByWhere ( $ conditions , $ options = [ ] ) { if ( ! is_array ( $ conditions ) ) { $ conditions = [ $ conditions ] ; } $ options = Util :: prepareOptions ( $ options , [ 'order' => false , ] ) ; // initialize conditions and order $ conditions = static :: _mapConditions ( $ conditions ) ; $ order = $ options [ 'order' ] ? static :: _mapFieldOrder ( $ options [ 'order' ] ) : [ ] ; return DB :: oneRecord ( 'SELECT * FROM `%s` WHERE (%s) %s LIMIT 1' , [ static :: $ tableName , join ( ') AND (' , $ conditions ) , $ order ? 'ORDER BY ' . join ( ',' , $ order ) : '' , ] , [ static :: class , 'handleError' ] ) ; }
Get the first result as an 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 Only takes 'order' option. A raw database string that will be inserted into the OR clause of the query or an array of field/direction pairs.
@return array|null First database result.
Get the first result as an array from a simple select query with a where clause you can provide .