Created
January 26, 2013 00:41
-
-
Save cam-gists/4639247 to your computer and use it in GitHub Desktop.
PHP : Short Active Record
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
public function updateOrder($data = array()) | |
{ | |
$sql = 'UPDATE `user` SET '; | |
foreach ($data as $key => $value) { | |
if(is_numeric($value)){ | |
$sql .= "`$key` = $value,"; | |
}else{ | |
$sql .= "`$key` = '$value',"; | |
} | |
} | |
$sql = substr($sql, 0, -1); | |
$sql .= ' WHERE id = ?'; | |
$sth = $this->dbh->prepare($sql); | |
$sth->execute(array($this->id)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment