通过TableGateway Object更新查询框架2

时间:2017-07-10 11:33:28

标签: php zend-framework zend-framework2 zend-db tablegateway

[10-Jul-2017 05:11:34 America/Denver] PHP Catchable fatal error:  Argument 1 passed to Zend\Db\Sql\Update::set() must be of the type array, object given, called in /home2/flywing1/vendor/zendframework/zend-db/src/TableGateway/AbstractTableGateway.php on line 336 and defined in /home2/flywing1/vendor/zendframework/zend-db/src/Sql/Update.php on line 93

我的输出打印:158123 它给了我在set()函数中传递数组,我已经作为参数传递。我也尝试将对象转换为数组((arrya)$ objetc)但它对我不起作用。

myLongPullingFunc(){
this.http.get(longPullingURL)
.subscribe(res=>{
  if(sholdFetchData){
    useFetchedData(res);
    this.myLongPullingFunc();
   }else
      doSomethingElse()
    })
 }

2 个答案:

答案 0 :(得分:2)

试试吧, 我遇到了同样的问题,我尝试过这个问题,并且它有效。

$rowset = $projectTable->update(array('statement_no' => '01010'), $where);

答案 1 :(得分:2)

您可以通过实施Zend\Db\Sql\Update对象来实现。您可以使用TableGateway创建该对象。您应该能够在模型中执行以下操作

public function update($set, $where)
{
    // Here is the catch  
    $update = $this->tableGateway->getSql()->update();
    $update->set($set);
    $update->where($where);

    // Execute the query
    return $this->tableGateway->updateWith($update);
}