有人可以告诉我这里我做错了什么吗?我有一张这样的桌子:
mysql> describe mytable;
Field Type Null Key Default Extra
-----------+----------+--------+--------+------------+---------------
id int(11) NO PRI NULL auto_increment
foreignid int(11) NO MUL NULL
date date NO '0000-00-00'
[some more columns]
我正在尝试通过preparedStatement插入值:
String insert = "insert into mytable (foreignid, date) values (?, ?)";
PreparedStatement pst = connection.prepareStatement(insert);
pst.setInt(1, newForeignID); //valid foreign key
pst.setDate(2, newDate); //newDate is a proper java.sql.Date
pst.execute();
这应该是相当简单的,但我总是得到这个错误:
Unknown column 'date' in 'field list'
知道为什么会这样吗?
答案 0 :(得分:1)
date是mysql中的关键字。你应该逃避或更好地重命名它:
<?php $this->beginContent('yourapp/views/container_view.php', ['model' => $model]) ?>
<div>this code is placed in $container</div>
<div>and the value of the var model is passed</div>
<br />
<?= $model->name '>
<?php $this->endContent() ?>