Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
enh(BE): get the prepare statement out of the while clause
Browse files Browse the repository at this point in the history
  • Loading branch information
sc979 committed Nov 14, 2019
1 parent 9df6718 commit 8e29ca3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions www/install/php/Update-19.10.2.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@
$stmt = $this->pearDB->query(
"SELECT contact_id, contact_name, contact_ldap_dn FROM contact WHERE ar_id is NOT NULL"
);
$updateDB = $this->pearDB->prepare(
"UPDATE contact SET contact_ldap_dn = :newDn WHERE contact_id = :contactId"
);
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
// removing the double slashes if needed and saving the corrected data
if (strpos($row['contact_ldap_dn'], "\\\\")) {
$newDn = str_replace("\\\\", "\\", $row['contact_ldap_dn']);
$updateDB = $this->pearDB->prepare(
"UPDATE contact SET contact_ldap_dn = :newDn WHERE contact_id = :contactId"
);

$updateDB->bindValue(':newDn', $newDn, \PDO::PARAM_STR);
$updateDB->bindValue(':contactId', $row['contact_id'], \PDO::PARAM_INT);
$updateDB->execute();
Expand Down

0 comments on commit 8e29ca3

Please sign in to comment.