向数据访问对象添加多个值 php
Add multiple values to data access object php
我想在单个数据访问对象中添加多个值:这可能吗?这是源代码:
array_push($spec, array('TYPE' => 'FRANCHISE', 'VALEUR' => utf8_decode($_REQUEST['cmbFranchise'])));
array_push($spec, array('TYPE' => 'PRO', 'VALEUR' => utf8_decode($_REQUEST['cmbIsPro'])));
array_push($spec, array('TYPE' => 'CORNER', 'VALEUR' => utf8_decode($_REQUEST['cmbCorner'])));
array_push($spec, array('TYPE' => 'SHOWROOM', 'VALEUR' => utf8_decode($_REQUEST['cmbIsShowroom'])));
$spec->insert();
事实上,我在数据库的 Polymag SCHEMA 中有一个名为 SPECIFITE 的 table,它正在替换 polymag.magasin 的列 isshowroom、iscorner、franchise 和 ispro table.
所以,现在新的table specificite由三列组成:'TYPE'、'VALEUR'和'NUMMAG'。 Polymag.magasin 中也指出了 Nummag。然后,'TYPE' 列将有四个可能的值:'FRANCHISE'、'PRO'、'CORNER'、'SHOWROOM',VALEUR 列将包含它的值。
其实前面代码写在"Action Script version 3"后面写在PHP.
这是解决方案:
private function saveSpecificiteMagasin($isNewMag, $nummag, $type, $valeur, $debugSave) {
$spec = dao::init('mdm.polymag.specificite');
$spec->NUMMAG = $nummag;
$spec->TYPE = $type;
$spec->VALEUR = $valeur;
if ($isNewMag == 0) {
return $spec->update($debugSave);
} else {
return $spec->insert($debugSave);
}
}
...
// On met à jour les spécificités liées au magasin
// On met à jour les spécificités liées au magasin
$retourSpecFranchise = $this->saveSpecificiteMagasin($isNewMag, $ret->NUMMAG, 'FRANCHISE', utf8_decode($_REQUEST['cmbFranchise']));
$retourSpecPro = $this->saveSpecificiteMagasin($isNewMag, $ret->NUMMAG, 'PRO', utf8_decode($_REQUEST['cmbIsPro']));
$retourSpecCorner = $this->saveSpecificiteMagasin($isNewMag, $ret->NUMMAG, 'CORNER', utf8_decode($_REQUEST['cmbCorner']));
$retourSpecShowRoom = $this->saveSpecificiteMagasin($isNewMag, $ret->NUMMAG, 'SHOWROOM', utf8_decode($_REQUEST['cmbIsShowroom']));
我想在单个数据访问对象中添加多个值:这可能吗?这是源代码:
array_push($spec, array('TYPE' => 'FRANCHISE', 'VALEUR' => utf8_decode($_REQUEST['cmbFranchise'])));
array_push($spec, array('TYPE' => 'PRO', 'VALEUR' => utf8_decode($_REQUEST['cmbIsPro'])));
array_push($spec, array('TYPE' => 'CORNER', 'VALEUR' => utf8_decode($_REQUEST['cmbCorner'])));
array_push($spec, array('TYPE' => 'SHOWROOM', 'VALEUR' => utf8_decode($_REQUEST['cmbIsShowroom'])));
$spec->insert();
事实上,我在数据库的 Polymag SCHEMA 中有一个名为 SPECIFITE 的 table,它正在替换 polymag.magasin 的列 isshowroom、iscorner、franchise 和 ispro table.
所以,现在新的table specificite由三列组成:'TYPE'、'VALEUR'和'NUMMAG'。 Polymag.magasin 中也指出了 Nummag。然后,'TYPE' 列将有四个可能的值:'FRANCHISE'、'PRO'、'CORNER'、'SHOWROOM',VALEUR 列将包含它的值。
其实前面代码写在"Action Script version 3"后面写在PHP.
这是解决方案:
private function saveSpecificiteMagasin($isNewMag, $nummag, $type, $valeur, $debugSave) {
$spec = dao::init('mdm.polymag.specificite');
$spec->NUMMAG = $nummag;
$spec->TYPE = $type;
$spec->VALEUR = $valeur;
if ($isNewMag == 0) {
return $spec->update($debugSave);
} else {
return $spec->insert($debugSave);
}
}
...
// On met à jour les spécificités liées au magasin
// On met à jour les spécificités liées au magasin
$retourSpecFranchise = $this->saveSpecificiteMagasin($isNewMag, $ret->NUMMAG, 'FRANCHISE', utf8_decode($_REQUEST['cmbFranchise']));
$retourSpecPro = $this->saveSpecificiteMagasin($isNewMag, $ret->NUMMAG, 'PRO', utf8_decode($_REQUEST['cmbIsPro']));
$retourSpecCorner = $this->saveSpecificiteMagasin($isNewMag, $ret->NUMMAG, 'CORNER', utf8_decode($_REQUEST['cmbCorner']));
$retourSpecShowRoom = $this->saveSpecificiteMagasin($isNewMag, $ret->NUMMAG, 'SHOWROOM', utf8_decode($_REQUEST['cmbIsShowroom']));