I have a database table which contain a float field ('ferate') and I have set the length to 15 and precision to 2. Whenever I execute a select statement like so, it returns a whole number. I would like to retrieve 'ferate' as a float with 2 decimal places. The default values for 'ferate' should be 44.86 but I am getting 45.
public function get_defaultrates () {
$defaultfuelrates = NULL; // array
if (!$this->dbconn->connect_errno) {
$stmt = $this->dbconn->prepare (
"SELECT * FROM dffuelexciserates"
);
$stmt->execute();
if ($stmt->errno === 0) {
$result = $stmt->get_result();
if ($result->num_rows >= 1) {
$defaultfuelrates = array ();
while ($row = $result->fetch_assoc()){
var_dump ($row);
$tr_dffuelexciserates = new tr_dffuelexciserates ();
$tr_dffuelexciserates->dfferid = $row['dfferid'];
$tr_dffuelexciserates->ftid = $row['ftid'];
$tr_dffuelexciserates->ferate = $row['ferate'];
array_push ($defaultfuelrates, $tr_dffuelexciserates);
}
}
$result->free();
}
$stmt->close();
}
return $defaultfuelrates;
}