Jump to content

ajax will help reduce php memory exhausted?


chaiwei

Recommended Posts

Hi,

 

I try to run a sync between two database.

1 is localhost in my pc and another 1 is on webserver (remote)

 

Okay, Let say I have 500,000 rows in a table, and I also just want to sync this table only.

I use a SELECT * FROM table, and then use while loop and generate a sql

 

Insert into xx VALUES ( xxx ), (xxx) ,(xxx) 

 

after that, I use ajax call to a script, pass the sql through ajax post method,

and use mysql_query to insert it into my pc.

 

However I keep getting exhausted memory,

 

         function query($sql) {
               
                      $resource = mysql_query($sql, $this->dbconnection);

                      if ($resource) {
                        if (is_resource($resource)) {
                          $i = 0;
                        
                          $data = array();
                      
                          while ($result = mysql_fetch_assoc($resource)) {
                            $data[$i] = $result;
                        
                            $i++;
                          }
                          
                          mysql_free_result($resource);
                          
                          $query = new stdClass();
                          $query->row = isset($data[0]) ? $data[0] : array();
                          $query->rows = $data;
                          $query->num_rows = $i;
                          
                          unset($data);

                          return $query;    
                          } else {
                          return TRUE;
                        }
                      } else {
                            exit('Error: ' . mysql_error($this->dbconnection) . '<br />Error No: ' . mysql_errno($this->dbconnection) . '<br />' . $sql);
                     }
              } 

 

I am not sure is this causing the exhausted memory issues.

 

is it this problem?

$query = new stdClass();

 

I wonder how bigdump handle the ajax call and even it import a million row of record in the table

it wouldn't have an memory issues.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.