0

Hi I have data to upload to a Mysql database and I need to get the time taken for each row to be inserted so that I can pass that number through to a progress bar. I have alreay tried accomplishing this by determining the number of rows affetced by the insertion then find the percentage of that number which is not the correct manner to do this.

here is the code

$result3=mysql_query("INSERT INTO dest_table.create_info SELECT * from Profusion.source_cdr") or   die(mysql_error());
$progress=mysql_affected_rows();

// Total processes
$total = $progress;
// Loop through process
for($i=1; $i<=$total; $i++){
// Calculate the percentage
$percent = intval($i/$total * 100)."%";
echo $percent;

this actually divides the total number of rows by 1 and multiplies by 100 to get the percentage and this is wrong .

I need the time taken for each row to be inserted and then find the percentage of that.

Your help will be highly appreciated.

4
Contributors
3
Replies
25
Views
3 Years
Discussion Span
Last Post by diafol
0

I need the time taken for each row to be inserted and then find the percentage of that.

You can't with the above code. By the time your code gets to the loop, the query has already been successfully completed.

0

What pritaeas says is (well, what else would you expect) right. To track progress, you'd have to separately select and insert those rows, which would - in this case - probably create an unnecessary delay in your operation.

Edited by minitauros

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.