0

我不想进行 zend 更新查询。

我正在查看zend 文档 ,但没有看到任何我想要的示例。

这个问题是否有人可以帮助我进行查询。

我想进行下一个查询:

Update cars set active = 0 
Where id in (SELECT idCar FROM UserCars Where idUser=3)
4

2 回答 2

3

也许更多 Zendy 方式:

$idUser = 3;
$sub_select
  = $db->select()
       ->from('UserCars', array('id'))
       ->where('idUser = ?', $idUser);

$updated_rows 
  = $db->update('cars', 
        array('active' => 0),
        "id IN ($sub_select)" 
    );
于 2012-08-28T15:29:37.353 回答
3

Simplest way to run any complex query. There can be some better ways to do same.

$sql = "Update cars set active = 0 
Where id in (SELECT idCar FROM UserCars Where idUser=3)";
$query = $this->getDbTable()->getAdapter()->query($sql, $data);
$query->execute(); 

Try this too

$data = array { 'active' = '0' };
$where = "id in (SELECT idCar FROM UserCars Where idUser=3)";
$db->update($data, $where);
于 2012-08-28T15:09:55.010 回答