0
votes

How can I do a bulk update in symfony using propel when my select criteria has joins in them? Here's an example of what I am trying to do.

$conn = Propel::getConnection(BudgetLinePeer::DATABASE_NAME);
// Create a Criteria object that will select the correct rows from the database
$selectCriteria = new Criteria();            
$selectCriteria->add(BudgetLinePeer::IDCOL1, $idcol1, Criteria::EQUAL);
$selectCriteria->addJoin(ProjectBudgetLinePeer::IDBUDGET_LINE, BudgetLinePeer::IDBUDGET_LINE);
$selectCriteria->add(ProjectBudgetLinePeer::IDCLIENT, $idclient, Criteria::EQUAL);
$selectCriteria->add(ProjectBudgetLinePeer::IDPROJECT, $project->getIdproject(), Criteria::EQUAL);
// Create a Criteria object includes the value you want to set
$updateCriteria = new Criteria();
$updateCriteria->add(BudgetLinePeer::STATUS, $status);
// Execute the query
BasePeer::doUpdate($selectCriteria, $updateCriteria, $conn);

I am trying to make an update(update new status) in table BudgetLine.

EDIT: Here's the snippet of the error I am getting:

Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/proj_ict_new/trunk/cbm/plugins/sfPropelORMPlugin/lib/vendor/propel/runtime/lib/util/BasePeer.php on line 369

This is related with the join statement. I tried to use useXYZQuery()->filterCon()->endUse(). but ended up with same error again.

1
And, what is the problem?j0k

1 Answers

0
votes

I was able to figure out another way to solve this problem. Here's the solution:

$budgetLine_ids = BudgetLineQuery::create()
                 ->filterByIdcol1($col1)
                 ->useProjectBudgetLineQuery()
                 ->filterbyIdproject()->endUse()->find()->toArray('budgetline_id');

$selectCriteria = BudgetLineQuery::create()->filterByIdbudgetLine(array_keys($budgetLine_ids));      

// Create a Criteria object includes the value you want to set
$updateCriteria = new Criteria();
$updateCriteria->add(BudgetLinePeer::STATUS, $status);
// Execute the query
BasePeer::doUpdate($selectCriteria, $updateCriteria, $conn);