Strange Database problem! PHP MySQL Codeigniter
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?
精彩评论