2013-10-21 45 views
0

當我採取一個陣列它`工作正常,但是當我採取捕致命錯誤:傳遞給學說 DBAL 連接::更新(參數3)必須是類型的陣列,在沒有更新的Symfony2行動給出

Catchable Fatal Error: Argument 3 passed to Doctrine\DBAL\Connection::update() must be of the type array, none given, called in D:\wamp\www\JPL\src\Jotun\TeamManagmentBundle\Controller\DefaultController.php on line 180 and defined in D:\wamp\www\JPL\vendor\doctrine\dbal\lib\Doctrine\DBAL\Connection.php line 497

這裏是我的控制器

public function updateAction() 
{ 



    $request = $this->getRequest(); 
    $company_name = $request->get('company_name'); 
    $team_name = $request->get('teamname'); 
    $mobileno = $request->get('mobileno'); 
    $email = $request->get('email'); 
    $em = $this->getDoctrine()->getManager(); 
    $conn = $this->get('database_connection'); 

    $conn->update('teams',array('company_name'=>$company_name,'team_name'=>$team_name,'mobile_no'=>$mobileno,'email_id'=>$email)); 

    return $this->redirect($this->generateUrl('jotun_teams')); 
} 

我沒有得到it.Thanks在提前

回答

1

需要在DBAL更新方法第三個元素。它必須包含關聯數組中的更新條件(字段值)。例如:

$conn->update(
    'teams', 
    array(  
     'company_name'=> 'NewCompanyName' 
     ), 
    array(
     'company_name' => 'CurrentCompanyName' 
     ) 
); 
相關問題