I have a mysql table with float variables. I want to pass them to mongodb collection, but when i do it, php convert my float variables into string. I've tried to use this code to set variable type as float but it returns me 1 in every field:
foreach( $mytables as $table => $struct ) {
$sql = mysql_query("SELECT num_auto FROM XL_10331_EXPLOIT_251012 where flightid like '191622'") or die( mysql_error() );
$count = mysql_num_rows( $sql );
// If it has content insert all content
if( $count > 0 ) {
while($info = mysql_fetch_row($sql)) {
$int_info=intval($info);
$mosql[]=($int_info);
}
// Starts new collection on mongodb
$collection = $modb->floatdb;
$collection->insert(array('num_auto'=>$mosql));
i can't find my mistake, any help will be really appreciated! Thanks!
$int_info=intval($info);it looks like you're forcing your value to an int.floatval()is in the question title, but not in the code.mysql_*functions will be deprecated in PHP 5.5. It is not recommended for writing new code as it will be removed in the future. Instead, either the MySQLi or PDO and be a better PHP Developer.