1

我在 Zend 框架中收到此错误:违反完整性约束:1048 列 'url_id' 不能为空

我的代码是:

$stmt = $this->select()->where('url_address = ?', $url_address)->query();       
        $r = $stmt->fetchAll();              
        print_r($r);
        if(count($r)==0){

            $data = array(
                'url_address'      => $url_address,
            );

            $this->insert($data);       

            $stmt = $this->select()->where('url_address = ?', $url_address)->query();                               
                         $r = $stmt->fetchAll();    

        }   

        echo $r->url_id;
        return $r->url_id;
4

1 回答 1

-1

这是一个 MySQL 错误,而不是真正的 PHP 错误。如果不会在此处插入任何内容,则需要将 url_id 字段的默认值设置为 NULL。

于 2011-05-05T17:49:51.760 回答