I have this sql query..
select i.invoiceid as transactionid, i.date, i.total,
'invoice' as transaction_type
from invoice
and I ran it in php and echo out the total in a foreach loop like so....
echo gettype($row['total']) . "<br/>";
and all the totals returned string
how would I convert the i.total in my sql query to int or float?
i've tried
convert(int, i.total)
and that didnt work :(
php handles everything (that's not an array/dictionary) as a string unless you specifically tell it not to with something like (int)$row['total']
.
http://php.net/manual/en/language.types.string.php#language.types.string.conversion
You could try
select i.invoiceid as transactionid, i.date, CAST(i.total as int) as total,
'invoice' as transaction_type
from invoice
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.