【发布时间】:2017-10-17 16:10:57
【问题描述】:
这里我要输入测试结果的值,这里的数据是基于整数的。
另外,我想加上其他测试结果值数据。
但是为什么当我输入这个基于整数的数据时,它的值总是四舍五入,或者我得到不合适的结果
在 Controller Exam.php 中
public function Exam()
{
$data_exam = array(
'subjects' => 'Natural Sciences',
'name_of_pupil' => 'Rizky Remangsa',
'the_pure_value_of_the_exam' => 5.6,
'addition_with_another_value' => 11.2,
'student_address' => 'Indonesia/Jakarta Selatan',
'graduation_status' => 'Not graduated yet'
);
$this->exam_model->insertDataExam($data_exam);
}
上面输入数据的结果是:
table the_pure_value_of_the_exam = 6
表添加_with_another_value = 11
【问题讨论】:
-
您尝试输入的值是浮点数,而不是整数
-
那么我如何输入该数据,但基于整数。 @NathanDawson
-
整数是整数,因此您看到的值 6 和 11 是正确的。它们已为您从浮点数转换为整数。要正确插入,您需要更改存储值的格式
-
你的意思是?将其种类更改为 Varchar,是这样吗? @NathanDawson
标签: php codeigniter mysqli phpmyadmin