我需要阅读和处理(例如在ID +末尾添加" 2"以及其他一些东西......)并使用PHP重新插入至少2000条记录。 使用SQL查询无法做到这一点...... 问题是,当我们点击Go按钮时,它会处理近500条记录,但随后我们会看到一个" Server Internal 500"错误!但是在localhost我们没有任何问题...
有没有办法在我们的客户网站上使用这些有限的资源来做到这一点?
另一个问题:是什么导致了这个问题?什么资源需要更多?内存? CPU?...?
这是代码: (我们应该阅读一个学期的所有课程和所有课程选择并将它们复制到新学期)
foreach ($courseList as $courseInfo)
{
$ccode=$courseInfo['ccode'];
$lid=$courseInfo['lid'];
$pid=$courseInfo['pid'];
$clid=$courseInfo['clid'];
$cgender=$courseInfo['cgender'];
$descriptive_score=$courseInfo['descriptive_score'];
$final_capacity=$courseInfo['final_capacity'];
$days_times=$courseInfo['days_times'];
$exam_date=$courseInfo['exam_date'];
$exam_place=$courseInfo['exam_place'];
$ccourse_start_date=date("Y-m-d H:i:s");
$ccomment=$courseInfo['ccomment'];
$cid=$courseInfo['cid'];
$majors=$course->GetCourseMajorsList($cid);
$scList=$course->GetCourseScoreColumnsList($cid);
$courseScoreColums=array();
foreach ($scList as $scProp)
{
$courseScoreColums[$scProp['scid']]=$scProp['scid'].','.$scProp['cscfactor'];
}
$tid = $term->LastTermID();
$counts = $course->AddCourse($ccode.'2',$tid,$lid,$pid,$clid,$majors,$courseScoreColums,$cgender,$descriptive_score,$final_capacity,$days_times,NULL,$exam_place,$ccourse_start_date,$ccomment,$aid);
if ($counts==1)
{
$new_cid = $course->LastCourseID();
$cs = new ManageCourseStudents();
$query = " WHERE `".$table_prefix."courses`.`cid`=$cid ";
$courseStudentList = $cs->GetCourseStudentList($query,'');
foreach ($courseStudentList as $csInfo)
$cs->AddCourseStudent($csInfo['uid'],$new_cid,$csInfo['lvid'],$aid);
}
}
答案 0 :(得分:0)
$str = "select * from tableName"; //replacing * by table columns is a good practice
$result = $conn->query($str);
while($arr = $result->fetch_array(MYSQLI_ASSOC);)
{
$strr1 = " INSERT INTO tableName ( `id` , `title` , `des` ) //add more
VALUES ( '".$arr['id']."2', '".$arr['something']."' //add as you require
";
if($conn->query($strr1) === false) {
trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
}
}
这可能会复制数据库中的每个数据