Skip to content

Instantly share code, notes, and snippets.

@Gesparo
Last active November 16, 2016 03:54
Show Gist options
  • Save Gesparo/d3e4aa4769d56bf4fe5430b450f615cb to your computer and use it in GitHub Desktop.
Save Gesparo/d3e4aa4769d56bf4fe5430b450f615cb to your computer and use it in GitHub Desktop.
Update fields in any table
/**
* 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