vendredi 15 juin 2018

Result is not print when value is 0

This is a function, its show result but when result 0 or null value, its not print and put blank space.when result is 0 its not print, what to do?

$holding_time = DB::table('trade')
        ->select(DB::raw('trade.*'))
        ->join('exchanges', 'trade.exchange_id', '=', 'exchanges.id')
        ->where('trade.user_id', $user_id)
        ->whereTime(DB::raw('IF(trade.buy_datetime<trade.sell_datetime, trade.buy_datetime, trade.sell_datetime) '), '>=', DB::raw('exchanges.start_time'))
        ->whereTime(DB::raw('IF(trade.buy_datetime<trade.sell_datetime, trade.buy_datetime, trade.sell_datetime) '), '<=', DB::raw("ADDTIME(exchanges.start_time, '01:00:00')"))
        ->select(DB::raw('SUM(TIMESTAMPDIFF(HOUR,buy_datetime, sell_datetime)) as first_hour_total_time'))
        ->first();
    return response()->json($holding_time);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire