php e mysql copiam registros de uma tabela para outra
Gostaria de arquivar um aluno movendo o registro de uma tabela para outra. Este é o código que estou tentando usar:
<?php
ini_set('memory_limit', '100M');
$sql="Select * from `register` where student_id=".$student_id;
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
//Call the function to archive the table
//Function definition is given below
archive_record(archive,$row);
//Once you archive, delete the record from original table
$sql = "Delete from `register` where student_id=".$student_id;
mysql_query($sql);
function archive_record($archived_tablename,$row)
{
$sql = "insert into $archived_tablename values(";
$i=0;
while($i<(count($row)-1))
{
$sql.="'".$row[$i]."',";
}
$i=$i+1;
$sql.="'".$row[$i]."'";
$sql.=")";
mysql_query($sql);
return true;
}
O problema que estou tendo é que estou recebendo um erro:
Erro fatal: falta de memória (alocada 80478208) (tentou alocar 80216043 bytes) em /archive-student.php na linha XX
Existe alguma maneira diferente de fazer isso, exceto por ter uma coluna chamada archive e mudar de 0 para 1? Isso ocorre porque eu tenho 30 a 50 páginas selecionando os registros da tabela. :)