Welcome Guest, Not a member yet? Register   Sign In
Page hangs on MYSQL Insert / Update
#1

[eluser]Mike DeFelice[/eluser]
I'm not too sure this falls into the Codeigniter category or not.

I am CI 2.02. Here is the problem, I have a transaction (locks up with or without using a transaction)

Code:
$this->db->trans_start();
            $this->db->set('meta_title', $this->input->post('meta_title'));
            $this->db->set('meta_keywords', $this->input->post('meta_keywords'));
            $this->db->set('meta_description', $this->input->post('meta_description'));
            $this->db->set('album_title', $this->input->post('album_title'));
            $this->db->set('album_url', $this->album_url);
            $this->db->set('galleryID', $this->input->post('gallery_id'));
            $this->db->set('date', date('F j, Y'));
            $this->db->set('siteID', $this->general->site_info_from_url('siteID', $this->input->post('site_url')), FALSE);        
            $this->db->insert(TABLE_ALBUMS);

            $this->db->set('total_albums', 'total_albums+1', FALSE);
            $this->db->where('galleryID', $this->input->post('gallery_id'));            
            $this->db->limit(1);          
            $this->db->update(TABLE_GALLERY);    

        $this->db->trans_complete();
        return $this->db->trans_status() !== FALSE;

now the form which corresponds to this transaction has a JQuery search to grab the gallery_id. Here is the problem, most of the time the site will just hang and nothing is added, I also tested with logging and it seems to get through the coding above but nothing gets added. However if I use the JQuery field right before submitting it goes through great every time. I am at a loss on what to do, I tried recreating the database, ram is good over a gig free, tried tuning mysql to see if that's it, nothing really seems to get it working.

Thank you so much if anyone can give me any insight into this problem.
#2

[eluser]JonoB[/eluser]
Trying logging the sql that the CI query produces, and then running the queries manually in phpmyadmin or whatever db tool you use.
#3

[eluser]Mike DeFelice[/eluser]
Good idea, I will try that. Thanks for your help.
#4

[eluser]InsiteFX[/eluser]
Maybe because your calling insert and update wrong! You do not need to use set with Active Record using the array method.
Code:
$data = array(
    'title' => 'My title' ,
    'name'  => 'My Name' ,
    'date'  => 'My date'
);

$this->db->insert('mytable', $data);

$data = array(
    'title' => $title,
    'name'  => $name,
    'date'  => $date
);

$this->db->where('id', $id);
$this->db->update('mytable', $data);

InsiteFX
#5

[eluser]Mike DeFelice[/eluser]
I thought using the set function was appropriate since some of the calls such as

Code:
$this->db->set('total_albums', 'total_albums+1', FALSE);

can not be escaped. The user guide says

$this->db->set();

This function enables you to set values for inserts or updates.

It can be used instead of passing a data array directly to the insert or update functions:
#6

[eluser]Mike DeFelice[/eluser]
I tried logging all mysql actions and it seems when it is locked up nothing is being sent to mysql. Also nothing is sent in the apache access logs, I am not really sure what is going on Smile




Theme © iAndrew 2016 - Forum software by © MyBB