Hi,

I am developing a custom module in drupal 6, which involves fetching data from remote server and performing multiple insert queries, but, i am having a strange problem, i've around 30 insert queries, but, only first five get executed, however, if i print queries and run them directly on my database, they get executed succesfully.

I've tried everything, but can't resolve that issue.

What can be the issue? Please suggest!

Thanks,
Kul.

Comments

VikrantR’s picture

Hi kuldeepkaundal,

I think it should be problem with your "maximum execution time" limit inside the php.ini
and for mysql too.

you should increase both of them.

Vikrant R

Anonymous’s picture

There's a chance you won't be able to do that if you're on shared hosting, if you can't then look at processing the records in a batch. There's a good batch example in the examples module.

Another way would be to combine the inserts into a single query:

$query = 'INSERT INTO myTable (field1, field2) VALUES ';
$inserts = array();
foreach ($my_data as $field1 => $field2) {
  $inserts[] = '(' . $field1 . ', ' . $field2 . ')';
}
$query .= implode(',', $inserts);
db_query($query);

That's a very basic example and shouldn't be used without some changes, it doesn't take into account potential SQL injection problems.