1

我遇到了一个返回表中行数的简单查询的奇怪问题。

这总是工作正常且正确。

然而!昨天我向我的网站添加了一个新功能,该功能可以更新表中现有行中的一列。这个函数叫做add_file()

现在我的网站给出了错误的值:

目前,从 phpMyadmin 和 SQLyog 查看的名为“procedure”的表中有76行。

但是在我的网站上说有70

机器不会说谎,所以这很可能是我做的

我有一种预感,我的函数add_file()是罪魁祸首。

如果用户上传了与该记录对应的文件,则此函数的作用是更新我的过程表中的“edocument”列。这样系统就知道该文件被称为什么,并可以为它构造一个 url。

        public function add_filename($file)
        {

            //This is the extension of the file retrieved from an array
            $extension = $file['upload_data']['file_ext'];


            //variable for updating row which is constructed from Username+Filename+Extension
            $filename = array
            (
                'edocument' => ($this->session->userdata('name').$this->input->post('record_id')).$extension
            );

            //find row that matches the row just submitted by user
            $this->db->where('procedure_id',$this->input->post('record_id'));
            //update that row with the filename of the document uploaded
            $this->db->update('procedure', $filename); 

        }

如果您查看此屏幕截图,您将看到我的 72-76 中的“电子文档”列具有值。

http://i.imgur.com/pBzVs.jpg

那么更新功能是否会破坏我的数据库?

谢谢

4

1 回答 1

1

你确定有76行吗?
我在您的图片列中看到patient_id,我猜它是自动增量(或者至少它与具有自动增量主键的患者表链接)。
但是,如果您运行了一些DELETE查询,您只会看到 70 行,但自动递增 id 将从最后使用的数字开始(在您的情况下从 76 开始)。

您是否尝试过运行简单COUNT查询(不使用 codeigniter 活动记录)?如果是,结果如何?

于 2011-07-31T22:37:11.650 回答