Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 检查CI+中的更新查询结果;SQL Server_Php_Mysql_Sql_Sql Server_Codeigniter - Fatal编程技术网

Php 检查CI+中的更新查询结果;SQL Server

Php 检查CI+中的更新查询结果;SQL Server,php,mysql,sql,sql-server,codeigniter,Php,Mysql,Sql,Sql Server,Codeigniter,这是我在CI的模型中的简单代码,名为时间表: $query = $this->db->update('CUST_GATH', array( 'new_email' => $data['new_email'], 'new_hp' => $data['new_hp'] ), array( 'name'=>$data['name'], 'hp'=

这是我在CI的
模型
中的简单代码,名为
时间表

$query = $this->db->update('CUST_GATH', 
      array(
           'new_email' => $data['new_email'],
            'new_hp' => $data['new_hp']
      ), 
      array(
          'name'=>$data['name'], 
          'hp'=>$data['hp'], 
          'email'=>$data['email']
      )
 );
return $query;
MySQL
中,我只需执行以下操作即可检查更新查询的结果:

$result = $this->schedule_m->update('schedule', $data);

if($result == true)
但这在SQL Server中不起作用。
$result
始终为真

我该怎么办

非常感谢你的帮助

更新

我试图使用受影响的行:

    $this->db->update('CUST_GATH', array('send_to' => $data['send_to'],
        'is_email' => 1), array('name'=>$data['name'], 'hp'=>$data['hp'], 'email'=>$data['email']));
    if ($this->db->affected_rows() > 0)
    {
        return true;
    }
    else
    {
        return false;
    }

但现在我的Web服务停止工作:
响应不包含任何数据。

这里怎么了

解决方法


我还没有解决这个问题,所以我的诀窍是在更新特定数据后选择,以检查数据是否更新。

您可以使用
JSON
输出尝试
受影响的行
方法:

if($this->db->affected_rows())
{
   return $this->output
                        ->set_content_type('application/json')
                        ->set_output(json_encode(array('OK')));
}


您必须使用受影响行的编号

$result = $this->schedule_m->update('schedule', $data);
if($this->db->affected_rows() > 0)
{
  return TRUE;
}else{
  return FALSE;
}

我应该在
controller
中使用
infected\u rows
?在其中编写更新查询,它在controller或model中的响应不包含任何数据。意味着您应该返回如下数据:
if($this->db->infected\u rows()){返回“OK”}
@BlazeTama您必须告诉我们您对web服务的期望是什么?在您的示例中,我希望它以JSON格式返回“OK”,非常感谢您的帮助。我将尝试您的解决方案:)
$result = $this->schedule_m->update('schedule', $data);
if($this->db->affected_rows() > 0)
{
  return TRUE;
}else{
  return FALSE;
}