Last active
November 16, 2016 03:54
-
-
Save Gesparo/d3e4aa4769d56bf4fe5430b450f615cb to your computer and use it in GitHub Desktop.
Update fields in any table
This file contains 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
/** | |
* Update fields in the table | |
* | |
* @param $table | |
* @param $project | |
* @param $projectIdColumnName | |
* @param $fields | |
* @return bool | |
* @internal param $projectId | |
*/ | |
function updateFields($table, $project, $projectIdColumnName, $fields) | |
{ | |
$projectQuery = is_array($project) ? "IN (".implode(',', $project).")" : "= '$project'"; | |
$query = DB::Query(" | |
UPDATE $table | |
SET ".prepareQuery($fields)." | |
WHERE $projectIdColumnName $projectQuery | |
"); | |
return false === $query ? false : true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment