dongxiezhi0590 2015-10-22 23:30
浏览 24
已采纳

MySQL IN关键字和Zend Framework 2用于更新查询

I am trying to use the IN keyword in MySQL to update across multiple rows. sessionsId is an array() of integer ids. I tried imploding them, but it fails with a syntax error because of what Zend adds to the query. Other posts on Stack Overflow use a subquery, but here the IDs aren't coming from another query. How could I accomplish the update using an IN query?

    $in = implode($sessionIDs,',');
    $update = new Update();
    $update->table("participantsToSessions");
    $update->set(array("subscribed" => intval($subscribed)));
    $update->where(array("participantId" => $participantId));
    $update->where(array("sessionsIds IN (?)"=> $in));
    //$str = $update->getSqlString();
    $this->tableGateway->updateWith($update);
  • 写回答

2条回答 默认 最新

  • dqcqcqwq38860 2015-10-22 23:45
    关注

    You don't need implode:

    $update->where(array('sessionsIds' => $sessionIDs));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?