Created
January 10, 2011 23:22
-
-
Save gavinblair/773693 to your computer and use it in GitHub Desktop.
lose the last comma off a list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$sql = "UPDATE coupons SET "; | |
foreach($args as $key => $arg) { | |
$arg = $this->db->escape($arg); | |
$key = $this->db->escape($key); | |
$sql .= "$key = $arg, "; | |
} | |
//lose the last comma | |
$sql = rtrim($sql, ", "); | |
$sql .= " WHERE coupon_code = $coupon_code"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment