/** * Duplique la table résultat de la clé étrangère * @param string $paramTable * @param string $paramId * @return int */ public static function duplicateRowsByIdReplaceLast($paramTable, $paramIdOLD, $paramIdNew) { /** * On récupère le nom du champ primaire de la table */ $primaryFieldName = self::getPrimaryFieldName($paramTable); $arrayField = DatabaseOperation::getArrayFiledsNamesTable($paramTable); $separation = ""; $separation2 = ""; foreach ($arrayField as $nomColumn) { if ($nomColumn != $primaryFieldName) { $tableListeInsert .= $separation . $nomColumn; $separation = ","; } if (stripos($nomColumn, self::LAST) === self::FALSE) { if ($nomColumn == FtaModel::KEYNAME) { $nomColumn = $paramIdNew; } $tableListeSelect .= $separation2 . $nomColumn; $separation2 = ","; } } $req = " INSERT INTO " . $paramTable . " (" . $tableListeInsert . ") " . " SELECT " . $tableListeSelect . " FROM " . $paramTable . " WHERE " . FtaModel::KEYNAME . "=" . $paramIdOLD; DatabaseOperation::executeComplete($req); }