note 55887 modified in function.mysqli-fetch-field by bjori

From: Date: Thu, 02 Mar 2006 09:58:39 +0000
Subject: note 55887 modified in function.mysqli-fetch-field by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-104691@lists.php.net to get a copy of this message
<? $fieldinfo = $result->fetch_field(); if ($fieldinfo & MYSQLI_NOT_NULL_FLAG) { print "not null flag is set"; } else { print "not null flag is NOT set"; } ?> --was-- <? define("MYSQLI_NOT_NULL_FLAG", 1); define("MYSQLI_PRI_KEY_FLAG", 2); define("MYSQLI_UNIQUE_KEY_FLAG", 4); define("MYSQLI_MULTIPLE_KEY_FLAG", 8); define("MYSQLI_BLOB_FLAG", 16); define("MYSQLI_UNSIGNED_FLAG", 32); define("MYSQLI_ZEROFILL_FLAG", 64); define("MYSQLI_BINARY_FLAG", 128); define("MYSQLI_ENUM_FLAG", 256); define("MYSQLI_AUTO_INCREMENT_FLAG", 512); define("MYSQLI_TIMESTAMP_FLAG", 1024); define("MYSQLI_SET_FLAG", 2048); define("MYSQLI_NUM_FLAG", 32768); define("MYSQLI_PART_KEY_FLAG", 16384); define("MYSQLI_GROUP_FLAG", 32768); define("MYSQLI_UNIQUE_FLAG", 65536); define("MYSQLI_BINCMP_FLAG", 131072); $fieldinfo = $result->fetch_field(); if ($fieldinfo & MYSQLI_NOT_NULL_FLAG) { print "not null flag is set"; } else { print "not null flag is NOT set"; } ?> From mysql_com.h 66 #define NOT_NULL_FLAG 1 /* Field can't be NULL */ 67 #define PRI_KEY_FLAG 2 /* Field is part of a primary key */ 68 #define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */ 69 #define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */ 70 #define BLOB_FLAG 16 /* Field is a blob */ 71 #define UNSIGNED_FLAG 32 /* Field is unsigned */ 72 #define ZEROFILL_FLAG 64 /* Field is zerofill */ 73 #define BINARY_FLAG 128 /* Field is binary */ 74 75 /* The following are only sent to new clients */ 76 #define ENUM_FLAG 256 /* field is an enum */ 77 #define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */ 78 #define TIMESTAMP_FLAG 1024 /* Field is a timestamp */ 79 #define SET_FLAG 2048 /* field is a set */ 80 #define NUM_FLAG 32768 /* Field is num (for clients) */ 81 #define PART_KEY_FLAG 16384 /* Intern; Part of some key */ 82 #define GROUP_FLAG 32768 /* Intern: Group field */ 83 #define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */ 84 #define BINCMP_FLAG 131072 /* Intern: Used by sql_yacc */ http://php.net/manual/en/function.mysqli-fetch-field.php

« previous php.notes (#104691) next »