开发者

Integrity constraint violation: 1048 Column 'url_id' cannot be null

I am getting this error in Zend Framework: Integrity constraint violation: 1048 Column 'url_id' cannot be null

My code is:

$stmt = $this->select()->where('url_address = ?', $url_address)->query();       
        $r = $stmt->fetchAll();              
        print_r($r);
        if(coun开发者_StackOverflowt($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;


That's a MySQL error, not really a PHP one. You need the url_id field to be a default value of NULL if nothing is going to be inserted there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜