[新增]
$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));
全站熱搜
留言列表