1

我正在使用 更新我的一个学说迁移中的实体Doctrine\DBAL\Migrations\AbstractMigration::addSql($sql, array $params = array(), array $types = array()),我必须将一列设置为空。

我已经对其进行了调试,并尝试将类型设置为,\PDO::PARAM_NULL但我遇到了同样的问题。

SQL:

    $sql="INSERT INTO sme_task_template (status_change_final_status) VALUES (:finalStatus)";
    $params=array(
        'finalStatus' => null
    );
    $types=array(
        'finalStatus' => \PDO::PARAM_NULL
    );
    $this->addSql($sql, $params, $types);

例外:

  [Doctrine\DBAL\DBALException]                                                
  An exception occurred while executing 'INSERT INTO sme_task_template (statu  
  s_change_final_status) VALUES (:finalStatus)' with params [null]:            
  Value for :finalStatus not found in params array. Params array key should b  
  e "finalStatus"

有谁知道如何解决这个问题?

谢谢

4

1 回答 1

1

I can't get it working with named parameters but it seems to work with question mark parameters.

    $sql="INSERT INTO sme_task_template_trigger (status_change_final_status) VALUES (?)";
    $params=array(
        null
    );
    $types=array(
        \PDO::PARAM_NULL
    );
    $this->addSql($sql, $params, $types);
于 2015-03-30T16:13:15.403 回答