I have a mapper class, OrganizationMapper
that saves data to multiple tables with the save
method. The save
method looks like this:
public function save(OrganizationInterface $organization) {
$action = new Insert('TABLE NAME');
$action->values([<SOME VALUES>]);
$sql = new Sql($this->dbAdapter);
$stmt = $sql->prepareStatementForSqlObject($action);
$result = $stmt->execute();
$action1 = new Insert('OTHER TABLE NAME');
$action1->values([OTHER VALUES]);
$sql1 = new Sql($this->dbAdapter);
$stmt1 = $sql1->prepareStatementForSqlObject($action1);
$result1 = $stmt1->execute();
...
}
There are a couple more cycles of $action#
, $sql#
, $stmt#
, $result#
.
How can I avoid these repetitive cycles?