开发者

Strange Database problem! PHP MySQL Codeigniter

开发者 https://www.devze.com 2023-03-25 10:23 出处:网络
I am experiencing a strange problem with a simple query that returned the number of rows in a table. This was always working fine and correct.

I am experiencing a strange problem with a simple query that returned the number of rows in a table.

This was always working fine and correct.

However! Yesterday I added a new function to my website that updates a column in existing rows in my table. This function called add_file()

Now my website is giving a wrong value of what it should be:

Currently there are 76 rows in my table called "procedure" viewed from phpMyadmin and SQLyog.

However in my website it is saying there are 70.

Machines DO NOT LIE, so this is most likely my doing

I have a hunch that my function called add_file() is to blame.

What this function does is update the "edocument" column in my procedure table if a user uploads a file corresponding to that record. So that the system knows what that file is called and can construct a url for it.

        public function add_filename($file)
        {

            //This is the extension of the file retrieved from 开发者_如何学Goan 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); 

        }

If you look at this screenshot you will see my "edocument" column from 72-76 has values.

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

So is the update function breaking my database?

Thanks


Are you sure that there are 76 rows?
I see in your picture column patient_id, I guess it is auto increment (or at least it is linked with patients table that have auto increment primary key).
But if you had run some DELETE queries you see only 70 rows, but the auto increment id will start from the last used number (from 76 in your case).

Have you tried running simple COUNT query (without using codeigniter active record)? If yes, what was the result?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号