我正在尝试使用UPDATE
编写PDO
查询,但我无法执行我的代码。
这是和UPDATE
函数,它按orderID
更新特定行。有什么想法吗?
function UpdateExistingEvent ($oID, $title, $range, $organizer, $chief,
$secretary, $coOrganizer, $shortDesc, $poster, $datebegin, $dateend,
$room, $roomEquipment, $cardHolterAmount, $cardHolderNames) {
try
{
$obj=new DBconnection();
$dhb=$obj->db_connect();
$sql = 'UPDATE `materialy.event` SET '
. '`title` = :title,'
. '`range` = :range, '
. '`organizer` = :organizer, '
. '`chief` = :chief, '
. '`secretary` = :secretary, '
. '`coOrganizer` = :coOrganizer, '
. '`shortDesc` = :shortDesc, '
. '`poster` = :poster, '
. '`dateBegin` = :dateBegin, '
. '`dateEnd` = :dateEnd, '
. '`room` = :room, '
. '`roomEquipment` = :roomEquipment, '
. '`cardHolderAmount` = :cardHolderAmount, '
. '`cardHolderNames` = :cardHolderNames '
. 'WHERE `orderID` = :orderID';
$stmt = $dhb->prepare($sql);
$stmt ->bindParam(':title', $title, PDO::PARAM_STR);
$stmt ->bindParam(':range', $range, PDO::PARAM_STR);
$stmt ->bindParam(':organizer', $organizer, PDO::PARAM_STR);
$stmt ->bindParam(':chief', $chief, PDO::PARAM_STR);
$stmt ->bindParam(':secretary', $secretary, PDO::PARAM_STR);
$stmt ->bindParam(':coOrganizer', $coOrganizer, PDO::PARAM_STR);
$stmt ->bindParam(':shortDesc', $shortDesc, PDO::PARAM_STR);
$stmt ->bindParam(':poster', $poster, PDO::PARAM_STR);
$stmt ->bindParam(':dateBegin', $datebegin, PDO::PARAM_STR);
$stmt ->bindParam(':dateEnd', $dateend, PDO::PARAM_STR);
$stmt ->bindParam(':room', $room, PDO::PARAM_INT);
$stmt ->bindParam(':roomEquipment', $roomEquipment, PDO::PARAM_STR);
$stmt ->bindParam(':cardHolderAmount', $cardHolterAmount, PDO::PARAM_INT);
$stmt ->bindParam(':cardHolderNames', $cardHolderNames, PDO::PARAM_STR);
$stmt ->bindParam(':orderID', $oID, PDO::PARAM_STR);
$stmt->execute();
$stmt->debugDumpParams();
if( $stmt->rowCount() )
{
echo '<div id="GAlert" class="CompleteAlertCentral">Complete!</div>';
}
else
{
echo '<div id="error">error!<div>';
}
}
catch(PDOException $e){
echo 'PDO Library Error: '.$e->getMessage();
}
}
我不知道出了什么问题。 INSERT
和READ
效果很好,但UPDATE
没有。请帮帮我。
答案 0 :(得分:1)
您的问题可能就在这一行:
UPDATE `materialy.event` SET
除非你的表名中有句号(这是可能的,但通常不太可能)。你可能意味着:
UPDATE `materialy`.`event` SET