我有一个包含许多字段的 PHP 表单。我想要的是动态地将字段添加到在 PostgreSQL 表中插入值的查询中,具体取决于这些字段的内容。如果字段(例如日期、整数等)为空,我不希望它出现在查询中,因为当我尝试插入表时它会导致“语法错误”,因为它等待插入值。请帮忙!
编辑
INSERT INTO hcd_customermeters ("meterSN", "contractCode",
"deviceManufacturer", "deviceType",
"firstInstallationDate", "diameter",
"pipeID", "operatorCreator", "warehouseDeliveryDate",
"recordCreation", "SRID")
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)'