由于我是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();
}
答案 0 :(得分:0)
对我来说,解决此问题的简单方法(更新):
$patient = Doctrine_Core::getTable('patient')->findOneById($patient_id);
$patient->setIsadmindnc(1);
$patient->save();
对于插入:
$patient = new Patient();
$patient->setIsadmindnc(1);
$patient->save();