public static function getRecordByField($field, $value, $cacheIndex = false)
    {
        $query = 'SELECT * FROM `%s` WHERE `%s` = "%s" LIMIT 1';
        $params = [
            static::$tableName,
            static::_cn($field),
            DB::escape($value),
        ];

        if ($cacheIndex) {
            $key = sprintf('%s/%s:%s', static::$tableName, $field, $value);
            return DB::oneRecordCached($key, $query, $params, [static::class,'handleError']);
        } else {
            return DB::oneRecord($query, $params, [static::class,'handleError']);
        }
    }
public static function getRecordByField($field, $value, $cacheIndex = false)
    {
        $query = 'SELECT * FROM `%s` WHERE `%s` = "%s" LIMIT 1';
        $params = [
            static::$tableName,
            static::_cn($field),
            DB::escape($value),
        ];

        if ($cacheIndex) {
            $key = sprintf('%s/%s:%s', static::$tableName, $field, $value);
            return DB::oneRecordCached($key, $query, $params, [static::class,'handleError']);
        } else {
            return DB::oneRecord($query, $params, [static::class,'handleError']);
        }
    }
public static function getRecordByField ( $ field , $ value , $ cacheIndex = false ) { $ query = 'SELECT * FROM `%s` WHERE `%s` = "%s" LIMIT 1' ; $ params = [ static :: $ tableName , static :: _cn ( $ field ) , DB :: escape ( $ value ) , ] ; if ( $ cacheIndex ) { $ key = sprintf ( '%s/%s:%s' , static :: $ tableName , $ field , $ value ) ; return DB :: oneRecordCached ( $ key , $ query , $ params , [ static :: class , 'handleError' ] ) ; } else { return DB :: oneRecord ( $ query , $ params , [ static :: class , 'handleError' ] ) ; } }
Get record by field.

@param string $field Field name
@param string $value Field value
@param boolean $cacheIndex Optional. If we should cache the result or not. Default is false.
@return array|null First database result.
Get record by field .