PHP dizide boş bir değer veren MySQL veritabanı 0,00 ondalık alanlar

1 Cevap php

Alanlar phpMyAdmin 0.00 olarak okumak, ama bir diziye koymak, değer sadece '0 'göstermek için almak için bir yol, boş var mi?

Benim Model Gönderen:

$query = $this->db->query("SELECT t1.numberofbets, t1.profit, t2.seven_profit, t3.28profit, user.user_id, username, 
PASSWORD , email, balance, user.date_added, activation_code, activated
FROM user
LEFT JOIN (

SELECT user_id, SUM( amount_won ) AS profit, COUNT( tip_id ) AS numberofbets
FROM tip
GROUP BY user_id
) AS t1 ON user.user_id = t1.user_id
LEFT JOIN (

SELECT user_id, SUM( amount_won ) AS seven_profit
FROM tip
WHERE date_settled >  '$seven_daystime'
GROUP BY user_id
) AS t2 ON user.user_id = t2.user_id
LEFT JOIN (

SELECT user_id, SUM( amount_won ) AS 28profit
FROM tip
WHERE date_settled >  '$twoeight_daystime'
GROUP BY user_id
) AS t3 ON user.user_id = t3.user_id
WHERE activated =1
GROUP BY user.user_id
ORDER BY user.date_added DESC 
LIMIT 0 , 30");

return $query->result_array();

Results in the database give : '0.00' for the seven_profit column. (column is a decimal type) with print_r($array) the array looks like '[seven_profit] => ' with no value there.

1 Cevap

Ben şimdi bu çözüm ile gittin:

 if ($row['fieldname'] == ''){
            $row['fieldname'] = 0;
    }

Teşekkürler