简体   繁体   中英

UPDATE QUERY propel 2


I have to do this query in my login database's table:

Update user set id_ditta = 1 WHERE id = 6 ;

I try to do this way (I have already created model):

$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);

The page gives me this error message:

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


I think that the page gives me this error because doUpdate method needs two arguments, I try to delete $update or $where but query doesn't work and the page gives me the error message.

How can I do?
Thanks.

Try using something like this:

$changeAz = 1;
$user = 6;

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM