Performance Symfony 1.4改进原则保存()方法
我的数据库中有500个条目。在我的后台,我有行动。例如:Performance Symfony 1.4改进原则保存()方法,performance,symfony1,doctrine,symfony-1.4,doctrine-1.2,Performance,Symfony1,Doctrine,Symfony 1.4,Doctrine 1.2,我的数据库中有500个条目。在我的后台,我有行动。例如: public function executeMyAction(sfWebRequest $request) { // Get some data from table $templates = Doctrine_Core::getTable('SeoTemplates')->findOneByEntity('training'); //Get data from other table(500 items) $trai
public function executeMyAction(sfWebRequest $request) {
// Get some data from table
$templates = Doctrine_Core::getTable('SeoTemplates')->findOneByEntity('training');
//Get data from other table(500 items)
$trainings = Doctrine::getTable('Training')->getTraining();
// Make some operations with data
foreach ($trainings as $training) {
$training->setSomeValue1('some_data');
$training->setSomeValue2('some_data');
$training->setSomeValue2('some_data');
}
// Problem part (try to save)
$trainings->save();
}
save()执行了很长时间。如何解决这个问题?可能吗
在我的问题部分,我有所有已知的错误致命错误:在保存每条记录而不是一个集合时,超过了30秒的最长执行时间
$templates = Doctrine_Core::getTable('SeoTemplates')->findOneByEntity('training');
$trainings = Doctrine::getTable('Training')->getTraining();
foreach ($trainings as $training) {
$training->setSomeValue1('some_data');
$training->setSomeValue2('some_data');
$training->setSomeValue2('some_data');
$training->save();
}
或者使用条令使用查询更新记录
$q = Doctrine_Query::create()
->update('TABLE')
->set($val1, '?', $val1)
->set($val2, '?', $val2)
->set($val3, '?', $val3)
->where('id = ?', $id)
->execute();
非常感谢。第二条路很快:-)