2014-08-27 55 views
0

由於我是新的symfony框架,爲我的客戶端symfony網站做維護。我試圖將一個記錄插入到一​​個新表中,該表實際上是一個已經存在的表的子表。Symfony插入子表

但我無法在此寫入插入查詢。僅顯示錯誤。

請檢查併爲下面的代碼的解決方案,

public function executeUpdatednc(sfWebRequest $request) 
    { 
     $patient_id = $_REQUEST['pid']; 

     $q = Doctrine_Query::create() 
     ->update('patient') 
     ->set('isadmindnc', '?', 1) 
     ->where('id = ?', $patient_id) 
     ->execute(); 

     $datetime = date("Y-m-d H:i:s"); 


#####  Here i need to write the sub query to insert into the new table, Please suggest ##### 


     //$rsm = new ResultSetMapping(); 
     //$query = $this->_em->createNativeQuery('INSERT INTO patient_phone SET ph_pid = ?', $patient_id); 
     //$query->setParameter(1, $items); 
     //$result = $query->getResult();   


    } 
+1

你正在使用1. *版我認爲,但標籤爲'symfony2' .. – xurshid29 2014-08-27 11:30:22

+0

是的,這是symfony 1,有沒有任何選擇要做到這一點,任何想法? – 2014-08-27 11:58:47

+0

對不起,我很樂意幫助你,但我從來沒有試過v1。* .. – xurshid29 2014-08-27 12:34:36

回答

0

對於我來說,簡單的方法來解決這個問題(更新):

$patient = Doctrine_Core::getTable('patient')->findOneById($patient_id); 
$patient->setIsadmindnc(1); 
$patient->save(); 

對於插入:

$patient = new Patient(); 
$patient->setIsadmindnc(1); 
$patient->save();