我在 CodeIgniter 4 上工作时收到此错误消息 - *语法错误、意外的“[”、需要标识符 (T_STRING) 或变量 (T_VARIABLE) 或“{”或“$”” *
class CreateProducts extends Migration
{
public function up()
{
$this->forge->addField([
'id' -> [ //error line
'type'-> 'INT',
'constraint'-> '11',
'unsigned' -> true,
'auto_increment' -> true,
],
'title' -> [
'type' -> 'VARCHAR',
'constraint' -> 255,
],
'description' -> [
'type' -> 'TEXT',
'null' -> true,
],
'price' -> [
'type' -> 'DECIMAL',
'constraint' -> '10,2'
]
]);
更新: 此处的解决方案https://codeigniter.com/user_guide/dbmgmt/migration.html?highlight=s