我想从SQL中选择的日期中选择上一条记录。
控制器
if ($this->input->post("show"))
{
$date=$this->input->post("date");
$where=array("date <="=>$date);
$result=$this->Common_model->select_previous("pso_meter",$where);
var_dump($result);
}
型
public function select_previous($table,$where)
{
$this->db->select("*");
$this->db->limit('1');
$this->db->order_by('date','DESC');
$query = $this->db->get_where($table, $where);
return $query->row();
}
控制器
if ($this->input->post("show"))
{
$date=$this->input->post("date");
$where=array("date <"=>$date);
$result=$this->Common_model->select_previous("pso_meter",$where);
var_dump($result);
}