使用doctrine + zf插入数据

时间:2011-07-08 12:17:10

标签: php database zend-framework doctrine

第一次使用Doctrine 2.0和Zend Framework ...

我只是添加一个事件,功能如下:

public function suggesteventAction(){
        $form = new Application_Form_Events();
        $form->setAction($this->view->url(array('controller' => 'events', 'action' => 'suggestevent')));
        //$form->area_of_interest_id->addMultiOptions($this->getInterestListAction());

        $this->view->form = $form;
        if($this->_request->isPost()){
            $formData = $this->getRequest()->getPost();

            if($form->isValid($formData)){
                $title                = $form->getValue('title');
                $area_of_interest_id  = $form->getValue('area_of_interest_id');
                $date_from            = $form->getValue('date_from');
                $date_to              = $form->getValue('date_to');
                $venue                = $form->getValue('venue');
                $company_logo         = $form->getValue('logo');
                $website              = $form->getValue('website');
                $email                = $form->getValue('email');
                $address              = $form->getValue('address');
                $city                 = $form->getValue('city');
                $state                = $form->getValue('state');
                $zip                  = $form->getValue('zip');
                $phone                = $form->getValue('phone_number');
                $short_description    = $form->getValue('short_description');
                $long_description     = $form->getValue('long_description');

                $event = new Default_Model_Event;

                $event->setTitle($title);
                $event->setUser_id(1);
                $event->setArea_of_interest_id(1);
                $event->setDate_from($date_from);
                $event->setDate_to($date_to);
                $event->setVenue($venue);
                $event->setAddress($address);
                $event->setCity($city);
                $event->setState($state);
                $event->setZip($zip);
                $event->setCountry($country);
                $event->setCompany_logo($company_logo);
                $event->setWebsite($website);
                $event->setEmail($email);
                $event->setPhone_number($phone);
                $event->setStatus('pending');
                $event->setShort_description($short_description);
                $event->setLong_description($long_description);

                $this->_em->persist($event);
                $this->_em->flush();
                Zend_Debug::dump($this->_em);
                die;
                $this->view->alert = 'Record saved successfully';
             } else {
                $form->populate($formData);
             }
        }    
    }//end function

现在正在刷新我收到错误...有一个表用于用户和感兴趣的区域,所以这两个是外键...

/**
 * @Entity
 * @Table(name="events")
 */
class Default_Model_Event
{
     /**
     * @Id @Column(name="id", type="integer")
     * @GeneratedValue(strategy="AUTO")
     */
    private $id;

    /** 
    * @Column(name="user_id", type="integer") 
    */
    private $user_id;

    /** 
    * @Column(name="title", type="string") 
    */
    private $title;

    /** 
    * @Column(name="area_of_interest_id", type="integer") 
    */
    private $area_of_interest_id;

    /** 
    * @Column(name="date_from", type="string") 
    */
    private $date_from;

找不到列:1054'字段列表'中的未知列'area_of_interest_id'

一切都很好,但不知道数据没有插入......

0 个答案:

没有答案