2016-07-08 31 views
0


我在我的登錄數據庫的表做此查詢:更新查詢推進2

Update user set id_ditta = 1 WHERE id = 6;

我嘗試做這樣(我已經創建的模型):

$changeAz = 1; 
$user = 6; 

$update = new Criteria(); 
$where = new Criteria(); 
$update->add(LoginTableMap::COL_ID_DITTA, $changeAz); 
$where->addAnd(LoginTableMap::COL_ID, $user); 
$con = Propel::getWriteConnection(\Model\Model\Map\LoginTableMap::DATABASE_NAME); 
LoginQuery::create()->doUpdate($update,$where, $con); 

頁給我這個錯誤消息:

Catchable fatal error: Argument 2 passed to Propel\Runtime\ActiveQuery\ModelCriteria::doUpdate() must implement interface Propel\Runtime\Connection\ConnectionInterface, instance of Propel\Runtime\ActiveQuery\Criteria given, called in C:\xampp\htdocs\work\fiogest\template\verifica\cambiaAzienda.php on line 19 and defined in C:\xampp\htdocs\work\fiogest\vendor\propel\propel\src\Propel\Runtime\ActiveQuery\ModelCriteria.php on line 1695


我認爲該網頁給我這個錯誤,因爲doUpdate方法需要兩個參數,我嘗試刪除$ update或$,但查詢不起作用,頁面給我提供錯誤信息。

我該怎麼辦?
謝謝。

+0

對不起我的問題我已經解決 –

回答

0

嘗試使用這樣的事情:

$changeAz = 1; 
$user = 6; 

LoginQuery::create() 
    ->filterById($user) 
    ->update([LoginTableMap::COL_ID_DITTA => $changeAz]);