symfony 使用 createQueryBuilder 如何插入数据库
我在 src/Entity/TestRepository 下面的加入如下方法,但是提示 找不到 insert 方法,求解答。
public function addOperGmLog($params)
{
$query = $this->createQueryBuilder('T');
$res = $query->insert('GmOperLog')
->values(array(
'serverId' => '?',
'userId' => '?',
'operType' => '?',
'operCode' => '?',
'operResult' => '?',
'operContent' => '?',
'operTime' => '?',
'operIp' => '?',
))
->setParameter(0, $params['serverId'])
->setparameter(1, $params['userId'])
->setparameter(2, $params['operType'])
->setparameter(3, $params['operCode'])
->setparameter(4, $params['operResult'])
->setparameter(5, $params['operContent'])
->setparameter(6, $params['operTime'])
->setparameter(7, $params['operIp']);
return $res;
}