我运行此代码但我没有更新
$sql="DATEDIFF(fecha_recepcion,now())";
$data=array('dias_restantes'=>$sql);
$this->db->where('estado',1);
$this->db->update('factura',$data);
我想做点什么
UPDATE `factura` SET `dias_restantes` = DATEDIFF(fecha_recepcion,now()) WHERE `estado` = 1
我想使用CodeIgniter的Active Record。
答案 0 :(得分:0)
<?php
$estado_id = 1;
$data = array(
'dias_restantes' => 'DATEDIFF(fecha_recepcion,now())'
);
$this->db->where('estado', $estado_id);
$this->db->update('factura', $data);
Si quieres ver los errores,utiliza。 $这 - &GT; DB-&GT; _error_message(); despuésde$ this-&gt; db-&gt; update()。
Te invito a que修改lapáginaoficial。 http://ellislab.com/codeigniter/user-guide/database/active_record.html
答案 1 :(得分:-1)
$this->db->query("UPDATE `factura` SET `dias_restantes` = DATEDIFF(fecha_recepcion,now()) WHERE `estado` = 1 ");