joomla 2.5 database query result returns every value as string datatype

295 Views Asked by At

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;?

1

There are 1 best solutions below

0
On BEST ANSWER

I dont really know if there is any other way ..But what I did was to add (int) before storing every int values from database like $intVar = (int)var_from_db;