を持っていない、一般的なエラー:1364フィールド 'エル' はこの問題を解決するためにどのようにデフォルト値
は、私のテーブル構造が
以下-insert機能のように見えた -CREATE TABLE
leave_histroy
(his_id
int(11) NOT NULL COMMENT 'histroy id auto increment',user_id
int(50) NOT NULL COMMENT 'get from users table id',cl
double(4,2) NOT NULL COMMENT 'casual leave',sl
double(4,2) NOT NULL COMMENT 'seak leave',el
double(4,2) NOT NULL COMMENT 'earned leave',mt
double(4,2) NOT NULL COMMENT 'maternity leave',pt
double(4,2) NOT NULL COMMENT 'paternity leave',lop
double(4,2) NOT NULL COMMENT 'loss of pay',compoff
double(4,2) NOT NULL COMMENT 'compensatory off leave',
year
year(4) DEFAULT NULL COMMENT 'store leave year',created_on
date DEFAULT NULL COMMENT 'created time',created_by
varchar(100) NOT NULL COMMENT 'created by whome?',updated_on
date DEFAULT NULL COMMENT 'updated time',updated_by
varchar(100) NOT NULL COMMENT 'updated by whom?') ENGINE=InnoDB DEFAULT CHARSET=latin1;
$query = "INSERT
INTO
`leave_histroy`(
`user_id`,
`cl`,
`sl`,
`year`,
`created_by`
)
VALUES(
:create_by,
:casual_leave,
:sick_leave,
:year,
:create_by
)";
try {
$result = $this->dbh->prepare($query);
$result->bindParam(":create_by", $leave_param['create_by']);
$result->bindParam(":casual_leave", $leave_param['casual_leave']);
$result->bindParam(":sick_leave", $leave_param['sick_leave']);
$result->bindParam(":year", $leave_param['year']);
$result->bindParam(":create_by", $leave_param['create_by']);
$result->execute();
return $result;
} catch (\PDOException $e) {
echo $e->getMessage();
die();
return false;
}
Tr ALTER TABLE 'leave_histroy'の後にyを変更します。' el''eel'' DOUBLE(4,2)NULL COMMENT 'earned leave';また、データを挿入していない場合は、他の列のデフォルト値を設定します。 –
Preparedステートメントに問題があります。チェックして、これを挿入しようとするとうまくいきます。ここを見てくださいhttps://www.w3schools.com/PhP/php_mysql_prepared_statements.asp – TarangP
すでにhis_idがプライマリキー – kalaivanan