Skip to content

Instantly share code, notes, and snippets.

@pfote
Created July 17, 2013 11:43
Show Gist options
  • Save pfote/6019768 to your computer and use it in GitHub Desktop.
Save pfote/6019768 to your computer and use it in GitHub Desktop.
function is_write_type($sql)
{
if (( ! preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql))
AND
( ! preg_match('/^\s*INSERT.*RETURNING\s+[\w\*,]+$/i', $sql))
)
{
return FALSE;
}
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment