-1

我使用以下代码从 db 表中打印计数值,现在我需要将此计数值插入表中,请帮助我。

 $this->db->like($data);
    $this->db->from('student_table');
    $result= $this->db->count_all_results();
    echo "count:".$result;

这只显示计数值

需要将count值插入到db表中

4

1 回答 1

1

它非常简单,在数据库中插入计数值,因为您没有提到要在其中插入计数的表名和属性/字段,我提出了一个一般性的答案!

使用插入查询

$this->db->like($data);
$this->db->from('student_table');
$result= $this->db->count_all_results();
$this->db->query("INSERT INTO tbl_name VALUES('$result')");

或者如果你想计算表中的所有行,

$result = $this->db->count_all('table_name');

使用更新查询

$this->db->where('id', $id);  // if particular value to update
$this->db->update('tblName', $result);
于 2013-09-26T04:21:57.703 回答