Ich versuche, eine flexible Update-Abfrage zu erstellen. Ich habe jetzt so etwas wie dieses:Erstellen einer flexiblen Update-Abfrage
$lsQuery = "UPDATE `";
$lsQuery .= $psTableName;
$lsQuery .= " SET ";
foreach($psValues as $lsKey => $lsValue)
{
$lsQuery .= $lsKey;
$lsQuery .= " = '";
$lsQuery .= $lsValue;
$lsQuery .= "' AND ";
}
$lsQuery .= "` ";
$lsQuery .= "WHERE ";
if(isset($psWhere)){
foreach($psWhere as $lsKey => $lsValue)
{
$lsQuery .= $lsKey;
$lsQuery .= " = '";
$lsQuery .= $lsValue;
$lsQuery .= "' AND ";
}
}
$lsQuery = substr($lsQuery,0,(strlen($lsQuery)-5));
Aber wenn ich meine Abfrage auf dem Bildschirm drucken bekomme ich so etwas wie:
UPDATE persons SET per_password = '2a6445462a09d0743d945ef270b9485b' AND
WHERE per_email = '[email protected]'
Wie kann Ich werde dieses zusätzliche 'UND' los?
tnx. Ich suchte nach einer Lösung, für die ich meine gesamte Update-Funktion nicht ändern müsste. – sanders