function actionMoveIsOut(){ $sql = 'select aid,type,is_out from job_resume_base'; $rst = $this->md->db->runsql($sql);
$mdResumeSearch = new job_ResumeForSearchM(); $i = 1; foreach($rst as $k => $v){ $mdResumeSearch->update("type={$v['type']},is_out={$v['is_out']} where aid={$v['aid']}"); echo "$i<br>"; $i++; } }表结构如下: id aid resume_id type is_out created 原来表里的type 和 is_out都是0,改成0或1
我估计是我的update里的where里的问题,我没有给aid建索引
为什么不直接用一句UPDATE来实现呢?
$mdResumeSearch->update("type={$v['type']},is_out={$v['is_out']} where aid={$v['aid']}");的后台代码是什么?更新的哪张表? 表结构是什么?利用下面语法 update t1 inner join t2 on t1.id=t2.id set t1.col=t2.colx where ...
还是你自己的程序慢,贴出来看一下。否则没办法分析。
$sql = 'select aid,type,is_out from job_resume_base';
$rst = $this->md->db->runsql($sql);
$mdResumeSearch = new job_ResumeForSearchM();
$i = 1;
foreach($rst as $k => $v){
$mdResumeSearch->update("type={$v['type']},is_out={$v['is_out']} where aid={$v['aid']}");
echo "$i<br>";
$i++;
}
}表结构如下:
id aid resume_id type is_out created
原来表里的type 和 is_out都是0,改成0或1
update t1 inner join t2 on t1.id=t2.id
set t1.col=t2.colx
where ...