[新增]

$sql = "INSERT INTO table_name(col1,col2,......coln) VALUES($var1,$var2,......$varn)";
$result = $db->exec($sql);

[修改]

$sql = "UPDATE dbname SET col1='$var1',col2='$var2',......coln='$varn' WHERE ......";
$result = $db->prepare($sql);
$result->execute();

[刪除]

$sql = "DELETE FROM dbname WHERE id=".$id."";
$result = $db->exec($sql);

[$db->prepare另外用法]

$sql = "UPDATE table_name SET col1=? WHERE col2=? AND col3=?";
$result = $db->prepare($sql);
$result->execute(array($var1,$var2,$var3));
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Vega 的頭像
    Vega

    Vega

    Vega 發表在 痞客邦 留言(1) 人氣()