Skip to content

Instantly share code, notes, and snippets.

@PurpleBooth
Created February 5, 2016 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PurpleBooth/013cfde768895aa706b7 to your computer and use it in GitHub Desktop.
Save PurpleBooth/013cfde768895aa706b7 to your computer and use it in GitHub Desktop.
protected static function getFieldFlags($what)
{
// Order of flags taken from http://lxr.php.net/xref/PHP_5_6/ext/mysql/php_mysql.c#2507
$constantFlagMap = [
MYSQLI_NOT_NULL_FLAG => "not_null",
MYSQLI_PRI_KEY_FLAG => "primary_key"
...
];
$flags = [];
foreach($constantFlagMap as $constant => $flag) {
if ($what & $constant) {
$flags[] = $flag;
}
}
return implode(" ", $flags);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment