简体   繁体   中英

joomla 2.5 database query result returns every value as string datatype

I was trying to get some database and trying to encode it in json format, the db table contains values of both int and varchar types

$db = $this->getDBO();
$query = "SELECT * FROM ".mt_table." WHERE user_id=".$userid;
$db->setQuery($query);  
$resulr= $db->loadObjectList();
var_dump($result);

I used a loadAssocList() first and encoded it to json string but every value was taken as string, var_dump() also shows string type.

How can I get result from database with datatype as it is in database, basically not convert everything into string maybe.... or do I need to explicitly make changes to int before I insert it into array using array1['key']=(int)myValue; ?

我真的不知道是否还有其他方法。但是我所做的是在存储$ intVar =(int)var_from_db;等数据库中的每个int值之前添加(int)。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM